Objective c 将self.presentingViewController显示在前台
代码中有ViewController A和B 当我按下按钮时,A显示B。然后在B中添加一个导航栏,其中有一个名为“返回上一屏幕”的导航项。然后我尝试这样做:当按下导航项时,执行以下代码返回到B的presentingViewController,在本例中,我认为它是AObjective c 将self.presentingViewController显示在前台,objective-c,ipad,cocoa-touch,Objective C,Ipad,Cocoa Touch,代码中有ViewController A和B 当我按下按钮时,A显示B。然后在B中添加一个导航栏,其中有一个名为“返回上一屏幕”的导航项。然后我尝试这样做:当按下导航项时,执行以下代码返回到B的presentingViewController,在本例中,我认为它是A [self presentViewController:self.presentingViewController animated:YES completion:nil]; 但不幸的是A没有出现。我在lldb中使用“print[
[self presentViewController:self.presentingViewController animated:YES completion:nil];
但不幸的是A没有出现。我在lldb中使用“print[self.presentingViewController class]”命令,我可以看到类是A。我做错了什么?为什么不将
UINavigationController
添加到“A”??这比你的逻辑更好更简单
只要按照我的密码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.AViewController = [[AViewController alloc] init];
self.navCon = [[UINavigationController alloc] initWithRootViewController:self.AViewController];
self.window.rootViewController = self.navCon;
[self.window makeKeyAndVisible];
return YES;
}
如果presentViewController:animated:completion“A呈现B”,则您可以通过以下方式返回A:
- (void) back: (id)sender
{
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}
是的,我知道。但我不希望UINavigationController显示在我的第一页上。除此之外,我还想知道为什么我的代码不工作,因为逻辑似乎很好。