Advanced IOS UI 02

Source: Internet
Author: User

01-pickerview Simple to use

I. Uipickerviewdatasource

// 返回有多少列- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;// 返回第component有多少行- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;

Two. Uipickerviewdelegate

Returns the width of column component-(CGFloat) Pickerview: (Uipickerview *) Pickerview widthforcomponent: (Nsinteger) componentReturns how high column component-(CGFloat) Pickerview: (Uipickerview *) Pickerview rowheightforcomponent: (Nsinteger) componentReturn to Column component row heading-(NSString *) Pickerview: (Uipickerview *) Pickerview Titleforrow: (Nsinteger) Row forcomponent: (Nsinteger) component//nsattributedstring: Rich Text, can describe the appearance of text properties, colors, fonts, shadows, hollow, graphic mixed //-(nsattributedstring *) Pickerview: (Uipickerview * ) Pickerview Attributedtitleforrow: (nsinteger) Row forcomponent: (nsinteger) component//Return to Column component row row view Control-( UIView *) Pickerview: (Uipickerview *) Pickerview Viewforrow: (nsinteger) row forcomponent: (Nsinteger) Component Reusingview: (UIView *) View//When the user selects a row, the call/ /is checked when the row row of the first component column is called/ /can listen Pickerview scroll-( void) Pickerview: (Uipickerview *) Pickerview Didselectrow: (nsinteger) row incomponent: (Nsinteger) Component            
02-Registration Interface

I. Uitextfielddelegate

// 是否允许改变文本框的文字// 是否允许用户输入文字// 作用:拦截用户的输入- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ return NO;}// 是否允许开始编辑// 允许编辑文本框- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField// 是否允许文本框结束编辑- (BOOL)textFieldShouldEndEditing:(UITextField *)textField

Two. Customizing the keyboard键盘由文本框inputView属性决定

Three. KVC Bottom-level implementation

Setvaluesforkeyswithdictionary Bottom-level implementationUsing KVC dictionary to model, [flag setvaluesforkeyswithdictionary:dict];1. Traverse all keys in the dictionary [dict enumeratekeysandobjectsusingblock:^ (ID Key,ID obj,BOOL *stop) {//2. Assign values to the properties of the model, using KVC, use the key in the dictionary as the model's property name, and the values in the dictionary are passed to the properties of the model. [flag setvalue:obj Forkey:key]; //name---icon //keypath: Property names in the model //property value //[flag setvalue:dict[@ "name"] forkey:@ "name"];//[flag setvalue:dict[@ "icon"] forkey:@ "icon"]; }]; //Setvalue:forkey: the underlying implementation //assigning values to the Icon property in the model //[flag setvalue:dict[@ "icon"] forkey:@ "icon"]; //1. First to find the model has a wood has SetIcon: method, directly call SetIcon: method, [Flag seticon:dict[@ "icon"]]//2. Then look for the property name of the icon in the model, and if so, directly assign the value icon = dict[@" icon "]//3. Then find out if there is any _ in the model Icon's property name, if any, is directly assigned _icon = dict[@ "icon"]//4. No, direct error, Setvalue:forundefinedkey:  

Four. Uidatepicker

    // 创建一个UIDatePicker    UIDatePicker *datePicker = [[UIDatePicker alloc] init];    // 设置日期模型    datePicker.datePickerMode = UIDatePickerModeDate;    // 设置地区,zh:中国    datePicker.locale = [NSLocale localeWithLocaleIdentifier:@"zh"]; // 监听UIDatePicker的选中的日期 [datePicker addTarget:self action:@selector(dateChange:) forControlEvents:UIControlEventValueChanged];
03-Loading the controller via storyboard

A. Uistoryboard: Loading storyboard files for you

    // UIStoryboard : 帮你加载storyboard文件    // 加载storyboard文件    // name:storyboard文件名,不需要后缀名    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; // 创建storyboard描述的控制器 // instantiateInitialViewController帮你加载箭头指向的控制器 UIViewController *vc = [storyboard instantiateInitialViewController]; // 根据标识符创建storyboard描述的控制器// UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"org"];
04-Creating a controller with Xib

I. Create a controller by Xib reason:

是想通过Xib描述控制器的viewTwo. How to create a controller from Xib

1.让xib与控制器产生联系,设置xib的文件拥有者是控制器,这时候xib就描述这个控制器 2.连线,告诉控制器是哪个view在描述
05-View creation of the controller

One.loadView

When to call:当第一次使用控制器的view的时候就会调用

Role:加载控制器的view,自定义控制器的view

Attention:

1. As long as you rewrite Loadview, you must manually create the controller's view

2. You cannot call Self.view until you assign a value to _view;

Two.loadView加载流程

Three. Xib Load controller's view

init底层会调用initWithNibName:bundle:

// 通过xib创建XMGViewController控制器的view// 1.判断下nibName有没有值,如果有值,就会去加载nibName指定的xib// 2.如果nibName为空,会先去查找有没有XMGView.xib,如果有就去加载// 3.如果没有XMGView.xib,就会去加载根类名同名的xib:XMGViewController.xib// 4.如果还没有找到,就生成一个空的view

Four. View delay loading of the controller

Five. Controller view the default is almost transparent

06-Basic use of the navigation controller

I. The navigation controller must have a root controller

Two. If the sub-controller of the navigation controller can get the navigation controller directly

Three. The Initwithrootviewcontroller layer is actually called the navigation controller's push method, the VC becomes the controller's sub-controller

Advanced IOS UI 02

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.