我得到了dismissModalViewControllerAnimated對以下設置正常工作,但很困惑,爲什麼它適用於自我(在modalViewController),而不是parentViewController。dismissModalViewControllerAnimated工作自我但不parentViewController
這裏的設置:
- 我有一個UITableViewController用導航按鈕調用了一個模式的看法:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Root";
_data = [NSArray arrayWithObjects:@"One", @"Two", nil];
_detailController = [[DetailViewController alloc] init];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showAbout)];
}
- (void)showAbout
{
AboutViewController *abv = [[AboutViewController alloc] init];
abv.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:abv animated:YES];
}
這裏的模態視圖控制器AboutViewController與工具欄按鈕觸發關閉模式的解僱動作:
- (IBAction)dismissAction:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
我的問題是爲什麼[自dismissModalViewControllerAnimated]工作,而不是[self.parentViewController dismissModalViewControllerAnimated]?這是iOS 5中的新功能嗎?我認爲只有parentViewController是可以解僱兒童模態視圖?
謝謝!
由於這是有道理的,現在是越來越糊塗了。 :) – LeoAlmighty 2012-01-13 06:58:42
哇感謝爲什麼蘋果要做到這一點... – minovsky 2012-08-29 13:07:12
'[self.presentingViewController dismissModalViewControllerAnimated:YES]!'被解僱,我目前看來我有3個級別的模式,並希望擺脫的2他們但這是帶我回第二級任何想法 – 2012-09-05 20:27:51