在我firstviewcontroller
我提出一個modalviewcontroller
,然後通過一個動作我打電話,顯示警報的方法和罷免modalview
,但是當它消失viewWillAppear中不叫:viewWillAppear中不叫modalviewwontroller
firstviewcontroller
-(IBAction)AddActivity:(id)sender{
CreateActivity *addViewController = [[CreateActivity alloc] initWithNibName:@"CreateActivity" bundle:nil];
addViewController.delegate = self;
addViewController.modalPresentationStyle = UIModalPresentationFormSheet;
addViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:addViewController animated:YES];
addViewController.view.superview.frame = CGRectMake(50, 260, 680, 624);
}
//in secondviewcontroller I use an alert view that call this method in order to dismiss modalview
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0){
if ([self respondsToSelector:@selector(presentingViewController)]){
[self.presentingViewController dismissModalViewControllerAnimated:YES];
}
else {
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
}
}
,當它消失,viewWillAppear
不叫,我所缺少的,請
感謝您的回覆,即使我添加viewwilldisappear時,它也無法訪問我的第一個視圖控制器的視圖 –
您是否正在使用導航控制器?你也可以發佈你的viewWillAppear代碼嗎? – dana0550
不,我只是目前modaly我的viewcontroller,並想解僱它,然後調用viewwillappear來做一些操作 –