CZPicker, 在 Objective C 中,选取器视图显示为iOS的弹出

分享于 

6分钟阅读

GitHub

  繁體 雙語
a picker view shown as a popup for iOS in Objective-C
  • 源代码名称:CZPicker
  • 源代码网址:http://www.github.com/chenzeyu/CZPicker
  • CZPicker源代码文档
  • CZPicker源代码下载
  • Git URL:
    git://www.github.com/chenzeyu/CZPicker.git
    Git Clone代码到本地:
    git clone http://www.github.com/chenzeyu/CZPicker
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/chenzeyu/CZPicker
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    CZPicker

    CI StatusVersionLicensePlatform

    演示

    更改日志

    这里列出了3 个最近的更改。

    完整的更改日志

    v0.4.3 2016-08-12

    • 添加 - (void)czpickerViewWillDisplay:(CZPickerView *)pickerView;
    • 添加 - (void)czpickerViewDidDisplay:(CZPickerView *)pickerView;
    • 添加 - (void)czpickerViewWillDismiss:(CZPickerView *)pickerView;
    • 添加 - (void)czpickerViewDidDismiss:(CZPickerView *)pickerView;
    • 添加了 - (void)reloadData 来重新加载选择器。
    • 添加 - (void)showInContainer:(id)container

    v0.4.2 2016-04-12

    • 改进方向处理程序以避免不必要的弹出动画。

    v0.4.1 2016-04-10

    • 删除podspec文件中的包资源设置。

    用法

    CZPicker可以通过 CocoaPods 获得。 要安装它,只需在你的Podfile中添加以下行:

    pod "CZPicker"

    要运行示例项目,克隆 repo,然后从示例目录中运行 pod install

    Swift

    如果你正在使用 Swift,请参考 Swift 演示项目。

    若要显示选取器,只需添加以下代码:

    CZPickerView *picker = [[CZPickerView alloc] initWithHeaderTitle:@"Fruits"cancelButtonTitle:@"Cancel"confirmButtonTitle:@"Confirm"];
    picker.delegate = self;
    picker.dataSource = self;
    [picker show];

    并实现数据源和委托方法:

    #prama mark - CZPickerViewDataSource@required/* number of items for picker */- (NSInteger)numberOfRowsInPickerView:(CZPickerView *)pickerView;@optional/* Implement at least one of the following method, czpickerView:(CZPickerView *)pickerView attributedTitleForRow:(NSInteger)row has higer priority*//* attributed picker item title for each row */- (NSAttributedString *)czpickerView:(CZPickerView *)pickerView
     attributedTitleForRow:(NSInteger)row;/* picker item title for each row */- (NSString *)czpickerView:(CZPickerView *)pickerView
     titleForRow:(NSInteger)row;
    #prama mark - CZPickerViewDelegate@optional/** delegate method for picking one item */- (void)czpickerView:(CZPickerView *)pickerView
     didConfirmWithItemAtRow:(NSInteger)row;/** delegate method for picking multiple items, implement this method if allowMultipleSelection is YES, rows is an array of NSNumbers*/- (void)czpickerView:(CZPickerView *)pickerView
     didConfirmWithItemsAtRows:(NSArray *)rows;/** delegate method for canceling */- (void)czpickerViewDidClickCancelButton:(CZPickerView *)pickerView;

    文档级自定义项

    有许多可以自定义的事件,更改以下属性来自定义你自己的选择器:

    /** whether to show footer (including confirm and cancel buttons), default NO */@property BOOL needFooterView;/** whether allow tap background to dismiss the picker, default YES */@property BOOL tapBackgroundToDismiss;/** whether allow selection of multiple items/rows, default NO, if this property is YES, then footerView will be shown */@property BOOL allowMultipleSelection;/** picker header background color */@property (nonatomic, strong) UIColor *headerBackgroundColor;/** picker header title color */@property (nonatomic, strong) UIColor *headerTitleColor;/** picker cancel button background color */@property (nonatomic, strong) UIColor *cancelButtonBackgroundColor;/** picker cancel button normal state color */@property (nonatomic, strong) UIColor *cancelButtonNormalColor;/** picker cancel button highlighted state color */@property (nonatomic, strong) UIColor *cancelButtonHighlightedColor;/** picker confirm button background color */@property (nonatomic, strong) UIColor *confirmButtonBackgroundColor;/** picker confirm button normal state color */@property (nonatomic, strong) UIColor *confirmButtonNormalColor;/** picker confirm button highlighted state color */@property (nonatomic, strong) UIColor *confirmButtonHighlightedColor;/** picker's animation duration for showing and dismissing*/@property CGFloat animationDuration;

    作者

    chenzeyu,zeyufly@gmail.com

    许可证

    CZPicker在MIT许可证下可用。 有关详细信息,请参阅许可证文件。

    Credits

    CZPicker是由 Fooyo.sg 创建并支持的。


    VIEW  对象  显示  POP  objective  pick  
    相关文章