我有一个 AppDelegate,它拥有一个窗口,从那里开始,一个主视图,当我转到下一个视图时,我推送新视图以使用相同的导航控制器和工具栏:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
self.appview = [[AppointmentView alloc] initWithNibName:@"AppointmentView" bundle:[NSBundle mainBundle]];
@synchronized(self.MahAppntmnts){ // Set the view's appointment
[appview setMyAppointment:[[MahAppntmnts MyAppointments] objectAtIndex:indexPath.section]];
}
[super addChildViewController:self.appview];
AppDelegate *del = (AppDelegate *)[UIApplication sharedApplication].delegate;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[del.navigationController pushViewController:self.appview animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
}
现在这可以很好地切换视图,但是当我试图返回时,我会得到同样无聊的翻转过渡。我尝试设置我的 AppView 的 viewWillDissapear 委托方法:
-(void) viewWillDisappear:(BOOL)animated
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
[super viewWillDisappear:animated];
}
这似乎适用于当我返回上一个视图时,但是当我尝试转换到新视图(使用与以前相同的方法)时,它们要么不出现,要么我翻转到同一个视图。所以我猜测这段代码不应该出现在 viewWillDissapear 上,或者我做错了什么......