-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
167 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// UIPickerView+RFKitTests.m | ||
// RFKit | ||
// | ||
// Created by BB9z on 2018/5/22. | ||
// Copyright © 2018 RFUI. All rights reserved. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "UIPickerView+RFKit.h" | ||
|
||
@interface RTUIPickerView : XCTestCase < | ||
UIPickerViewDataSource | ||
> | ||
|
||
@end | ||
|
||
@implementation RTUIPickerView | ||
|
||
- (void)testSelectRow { | ||
UIPickerView *p = UIPickerView.alloc.init; | ||
p.dataSource = self; | ||
XCTAssertThrows([p selectRow:-1 inComponent:NSNotFound animated:YES]); | ||
XCTAssertNoThrow([p rf_selectRow:5 inComponent:5 animated:YES]); | ||
} | ||
|
||
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { | ||
return 2; | ||
} | ||
|
||
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { | ||
return 2; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*! | ||
UIPickerView extension | ||
RFKit | ||
Copyright (c) 2018 BB9z | ||
https://github.com/BB9z/RFKit | ||
The MIT License (MIT) | ||
http://www.opensource.org/licenses/mit-license.php | ||
*/ | ||
#import "RFFoundation.h" | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIPickerView (RFKit) | ||
|
||
/** | ||
Safely selects a row in a specified component of the picker view. | ||
If any index is not in the legal range, this method do nothing. | ||
@param row A zero-indexed number identifying a row of component. | ||
@param component A zero-indexed number identifying a component of the picker view. | ||
@param animated `YES` to animate the selection by spinning the wheel (component) to the new value; if you specify `NO`, the new selection is shown immediately. | ||
*/ | ||
- (void)rf_selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated API_AVAILABLE(ios(2.0)); | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
#import "UIPickerView+RFKit.h" | ||
|
||
@implementation UIPickerView (RFKit) | ||
|
||
- (void)rf_selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated { | ||
if (component < 0 || component >= self.numberOfComponents) return; | ||
if (row <0 || row >= [self numberOfRowsInComponent:component]) return; | ||
[self selectRow:row inComponent:component animated:animated]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters