一. Modal segue
1. Unwind segue
显示model后,返回,需要实现Unwind segue;
2. 代码关闭model
a. 调用方调用该接口
- (void)dismissViewControllerAnimated:(BOOL)animated
completion:(void(^)(void))block;
b. Modal view 自己关闭
[self.presentingViewCOntroller dismissViewControllerAnimated:YES...];
3. Modal view 显示时动画类型
@property UIModalTransitionStyle modalTransitionStyle;
4. iPad 显示时,可设置mode进入时的样式
@property UIModalPresentationStyle modalPresentationStyle;
二. UITextField
1. 显示,隐藏键盘
becomeFirstResponder, resignFirstResponder
2. delegate
a. 按return key:
- (BOOL)textFieldShouldReturn:(UITextField*)sender;
b. 编辑结束(即不再是第一响应器时)
- (void)textFieldDidEndEditing:(UITextField*)sender;
3. text 被改变时,会发送消息:UITextFieldTextDidChangeNotification 消息
4. Keyboard
UITextInputTraits protocol 里的属性,可以设置键盘的样式
5. 键盘显示时,覆盖其他view,所以需要注册下面消息,知道键盘的区域,并调整UI:
UIKeyboardWillShowNotifications,(DidShow,WillHide,DidHide)
注:UITableViewCOntroller 会自动监听这些消息,自动改变大小。
三. 动作表单和警告
1. UIActionSheet
a. 显示 action sheet
[actionSheet showInView:view]; /// iPhone上使用,从下滑上来
[actionSheet showFromRect:rc inView:view animated:YES]; /// iPad 使用在某个区域显示
[actionSheet showFromBarButtonItem:barBtnItem animated:YES]; /// iPad 使用,弹出来
b. delegate - 点击后
- (void)actionSheet:(UIActionSheet*)sender didDismissWithButtonIndex:(NSInteger)index;
各个Button的Index:
@property NSInteger cancelButtonIndex;
... destructiveButtonIndex;
... firstOtherButtonIndex;
... numberOfButotns;
c. 代码中关闭action sheet
- (void)dismissWithClickedButtonIndex:(NSInteger)index animated:(BOOL)animated;
2. UIAlertView
a. 设置带输入框或密码框的Alert
alert.alertViewStyle = UIAlertViewStyle{SecureText,PlainText,LoginAndPassword}Input;
[alertView textFieldAtIndex:0] // UITextField类型时,如果是LoginAndPassword类型时,1为获取密码;
四. demo - good!