模态跳转中Controller的从属
在我们进行控制器的跳转时,只要控制器没有被释放,我们都可以顺藤摸瓜的找到它,使用如下两个方法:
1
2
3
4
|
//其所present的contller,比如,A和B两个controller,A跳转到B,那么A的presentedViewController就是B
@property(nullable, nonatomic,readonly) UIViewController *presentedViewController NS_AVAILABLE_IOS(5_0);
//和上面的方法刚好相反,比如,A和B两个controller,A跳转到B,那么B的presentingViewController就是A
@property(nullable, nonatomic,readonly) UIViewController *presentingViewController NS_AVAILABLE_IOS(5_0);
|
1
2
|
self.presentingViewController.view.backgroundColor = [UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:1];
[self dismissViewControllerAnimated:YES completion:nil];
|