zoukankan      html  css  js  c++  java
  • UIPickerView採摘控件的學習

    //
    //  UIPickerView.h
    //  UIKit
    //
    //  Copyright (c) 2006-2014 Apple Inc. All rights reserved.
    //

    #import <Foundation/Foundation.h>
    #import <CoreGraphics/CoreGraphics.h>
    #import <UIKit/UIView.h>
    #import <UIKit/UITableView.h>
    #import <UIKit/UIKitDefines.h>

    @protocol UIPickerViewDataSource, UIPickerViewDelegate;

    NS_CLASS_AVAILABLE_IOS(2_0) @interface UIPickerView : UIView <NSCoding, UITableViewDataSource>

    @property(nonatomic,assign) id<UIPickerViewDataSource> dataSource;                // default is nil. weak reference 數據源  默認為nil,弱引用
    @property(nonatomic,assign) id<UIPickerViewDelegate>   delegate;                // default is nil. weak reference  代理   默認為nil,弱引用
    @property(nonatomic)        BOOL                       showsSelectionIndicator;    // default is NO 顯示選中指示器 默認為NO

    // info that was fetched and cached from the data source and delegate
    //從代理跟數據源中 接收 跟 存儲 信息
    @property(nonatomic,readonly) NSInteger numberOfComponents; //返回列數
    - (NSInteger)numberOfRowsInComponent:(NSInteger)component; //返回對應列的行數
    - (CGSize)rowSizeForComponent:(NSInteger)component; //返回對應列,行的尺寸

    // returns the view provided by the delegate via pickerView:viewForRow:forComponent:reusingView:
    // or nil if the row/component is not visible or the delegate does not implement
    // pickerView:viewForRow:forComponent:reusingView:
    - (UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component;//返回

    // Reloading whole view or single component //刷新全部或者單個列
    - (void)reloadAllComponents; //刷新所有列
    - (void)reloadComponent:(NSInteger)component; //刷新指定列

    // selection. in this case, it means showing the appropriate row in the middle 選擇,在著紅情況下,这意味着在中间显示适当的行
    - (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated;  // scrolls the specified row to center. //滑動指定的列到中心

    - (NSInteger)selectedRowInComponent:(NSInteger)component;                                   // returns selected row. -1 if nothing selected  //根據指定列返回指定row,如果,沒有選擇任何東西,返回 ﹣1

    @end


    @protocol UIPickerViewDataSource<NSObject> //UIPickerView的數據源協議
    @required

    // returns the number of 'columns' to display.  返回要顯示的總列數
    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;

    // returns the # of rows in each component.. 返回每一列的行數
    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
    @end


    @protocol UIPickerViewDelegate<NSObject>
    @optional

    // returns width of column and height of row for each component.  返回每列對應每一行的高跟寬
    - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component;//返回的是寬
    - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component;//返回的是高

    // these methods return either a plain NSString, a NSAttributedString, or a view (e.g UILabel) to display the row for the component.
    //這些方法返回,單一的字符串或者帶有屬性修飾的字符串,或者view
    // for the view versions, we cache any hidden and thus unused views and pass them back for reuse.
    //
    // If you return back a different object, the old one will be released. the view will be centered in the row rect  
    //如果你返回不同的對象,舊的哪一個會被釋放掉。返回的那個view會在行中心
    - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component; //返回列對應的行的標題
    - (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component NS_AVAILABLE_IOS(6_0); // attributed title is favored if both methods are implemented
    - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view; //返回自定義的view

    - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component; //選中對應列對應行的方法

    @end

  • 相关阅读:
    SDU暑期集训排位(8)
    hdu1423 最长公共上升子序列
    poj2385 Apple Catching (线性dp)
    hdu5857 Median(模拟)
    hdu5858 Hard problem(求两圆相交面积)
    shuoj 1 + 2 = 3? (二分+数位dp)
    Codeforces Round #460 (Div. 2) B Perfect Number(二分+数位dp)
    hdu4734 F(x)(数位dp)
    hdu3709 Balanced Number (数位dp)
    hdu3652 B-number(数位dp)
  • 原文地址:https://www.cnblogs.com/yanshinian/p/4175946.html
Copyright © 2011-2022 走看看