在A页面的一个功能进行两种不同顺序的push操作时的执行结果区分:
第一种执行方式:
fxjcheckinfoViewController *checkView = [[fxjcheckinfoViewController alloc] initWithNibName:
@"fxjcheckinfoViewController" bundle:nil];
checkView.isAccess = self.isPass;
checkView.picNumber = self.picNumber;
[self.navigationController pushViewController:checkView animated:NO];
[checkView release];
[self.cameraPicker dismissModalViewControllerAnimated:NO];
UIWindow *tmpWindow = [[UIApplication sharedApplication] keyWindow];
UIButton *tmpBtn1 = (UIButton *)[tmpWindow viewWithTag:BTNTAG1];
UIButton *tmpBtn2 = (UIButton *)[tmpWindow viewWithTag:BTNTAG1];
tmpBtn1.hidden = NO;
tmpBtn2.hidden = NO;
UIView *bgView = (UIView *)[tmpWindow viewWithTag:WINVIEWTAG];
[bgView removeFromSuperview];
第二种执行方式:
[self.cameraPicker dismissModalViewControllerAnimated:NO];
UIWindow *tmpWindow = [[UIApplication sharedApplication] keyWindow];
UIButton *tmpBtn1 = (UIButton *)[tmpWindow viewWithTag:BTNTAG1];
UIButton *tmpBtn2 = (UIButton *)[tmpWindow viewWithTag:BTNTAG1];
tmpBtn1.hidden = NO;
tmpBtn2.hidden = NO;
UIView *bgView = (UIView *)[tmpWindow viewWithTag:WINVIEWTAG];
[bgView removeFromSuperview];
fxjcheckinfoViewController *checkView = [[fxjcheckinfoViewController alloc] initWithNibName:
@"fxjcheckinfoViewController" bundle:nil];
checkView.isAccess = self.isPass;
checkView.picNumber = self.picNumber;
[self.navigationController pushViewController:checkView animated:NO];
[checkView release];
对于上面两种执行方式,其目的时要从这里的A页面push到通过代码定义得checkView页面(B页面),但是两种代码执行的结果却不相同。其中第一种正确显示了需要的结果,而第二种方式则是一个不需要的执行方式。两种执行结果和执行顺序到底是怎样的呢?(注:在这里,需要先说明:在A页面是有viewDidAppear函数操作的,而对于viewController在执行当前页面显示时,是要执行viewDidAppear操作的。)
对于第一种执行方式,首先执行
fxjcheckinfoViewController *checkView = [[fxjcheckinfoViewController alloc] initWithNibName:
@"fxjcheckinfoViewController" bundle:nil];
checkView.isAccess = self.isPass;
checkView.picNumber = self.picNumber;
[self.navigationController pushViewController:checkView animated:NO];
[checkView release];
通过push功能将B页面push到(UINavigationController)栈顶, 同时A页面的显示操作被作为第一相应页面,在此功能模块执行完毕后,将执行其显示操作,然后对A页面进行
[self.navigationController pushViewController:checkView animated:NO];
操作,对A页面进行修改。这样一来当前页面(UINavigationController的栈顶页面)虽然A页面有所修改,但是位于栈顶的仍然是B页面而非A页面,所以接下来将执行我们需要的B页面,而将A页面的viewDidAppear延时执行。
但是对于第二种操作,首先执行 [self.navigationController pushViewController:checkView animated:NO];由于有Controller操作,所以其被作为了第一相应页面,在执行完气候的代码之后,将接着执行A页面的viewDidAppear操作,而将其后的页面置延时执行。