UI进阶8 Segue Modal UITabBarContro

2016-08-13  本文已影响66人  SoManyDumb

什么是Segue

Segue的属性

唯一标识
@property (nonatomic, readonly) NSString *identifier;
来源控制器
@property (nonatomic, readonly) id sourceViewController;
目标控制器
@property (nonatomic, readonly) id destinationViewController;

Segue的类型

自动型Segue

手动型Segue

[self performSegueWithIdentifier:@"login2contacts" sender:nil];
// Segue必须由来源控制器来执行,也就是说,这个perform方法必须由来源控制器来调用

performSegueWithIdentifier:sender:

[self performSegueWithIdentifier:@“login2contacts” sender:nil];
// 这个self是来源控制器
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender;
// 这个sender是当初performSegueWithIdentifier:sender:中传入的sender

Sender参数的传递

[self performSegueWithIdentifier:@“login2contacts” sender:@“jack”];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender;


控制器的数据传递

UITabBarController

UITabBarController的简单使用

UITabBarController的子控制器

添加单个子控制器
- (void)addChildViewController:(UIViewController *)childController;

设置子控制器数组
@property(nonatomic,copy) NSArray *viewControllers;

UITabBar

UITabBarButton

标题文字
@property(nonatomic,copy) NSString *title;

图标
@property(nonatomic,retain) UIImage *image;

选中时的图标
@property(nonatomic,retain) UIImage *selectedImage;

提醒数字
@property(nonatomic,copy) NSString *badgeValue;

Modal

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion

关闭当初Modal出来的控制器
- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion;
上一篇 下一篇

猜你喜欢

热点阅读