Lau*_*ell 3 iphone xcode uinavigationcontroller
我正在使用导航控制器.我的RootViewController推送了许多视图,但它也提供了一个模态视图.该模态视图提供了一个tableView.所以我想要做的就是弄清楚我可以将导航控制器推到模态视图中,然后在该模态视图中使用它来推送带有tableView的视图?或者除此之外,有没有办法从模态视图实现第二个导航控制器?
真正的问题是我想使用从右到左过渡的tableView来呈现视图,这当然不适用于模态视图.
我有这个代码,SORT OF提供了导航控制器使用的左转换权限:
NewViewController *newViewController = [[NewViewController alloc] init];
[self presentModalViewController:newViewController animated:NO];
CGSize theSize = CGSizeMake(320, 460);
newViewController.view.frame = CGRectMake(0 + theSize.width, 0 + 20, theSize.width, theSize.height);
[UIView beginAnimations:@"animationID" context:NULL];
[UIView setAnimationDuration:0.5];
newViewController.view.frame = CGRectMake(0, 0 + 20, 320, 460);
[UIView commitAnimations];
[newViewController release];
Run Code Online (Sandbox Code Playgroud)
问题是OldViewController(调用NewViewController的那个)立即消失,因此NewViewController在空白屏幕上转换,而不是覆盖OldViewController.
小智 10
以模态方式呈现UIViewController会创建一个全新的导航堆栈.你可以这样做:
//Create the view you want to present modally
UIViewController *modalView = [[UIViewController alloc] init];
//Create a new navigation stack and use it as the new RootViewController for it
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:modalView];
//Present the new navigation stack modally
[self presentModalViewController:nav animated:YES];
//Release
[modalView release];
[nav release];
Run Code Online (Sandbox Code Playgroud)
这可以完成,因为UINavigationController是UIViewController的子类.加载新视图时,您可以根据需要使用它(按下它上面的另一个视图,像Waqas建议的UIView动画等等).
我希望我能正确地回答你的问题.如果我没有,请告诉我.
| 归档时间: |
|
| 查看次数: |
3831 次 |
| 最近记录: |