0

我试图让我的应用在用户单击“提交”按钮后切换视图。

这是我到目前为止所拥有的:

视图A.h

@property (nonatomic, retain) RootViewController *root;

视图A.m

-(void)switchToLogView{

NSLog(@"switch to log view");

UIViewController <SubstitutableDetailViewController> *detailViewController = nil;
LogDetailViewController *newDetailViewController = [[LogDetailViewController alloc] initWithNibName:@"LogDetailViewController" bundle:nil];
detailViewController = newDetailViewController;

// Update the split view controller's view controllers array.
NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil];
root.splitViewController.viewControllers = viewControllers;

// Dismiss the popover if it's present.
if (root.popoverController != nil) {
    [root.popoverController dismissPopoverAnimated:YES];
}

// Configure the new view controller's popover button (after the view has been displayed and its toolbar/navigation bar has been created).
if (root.rootPopoverButtonItem != nil) {
    [detailViewController showRootPopoverButtonItem:self.root.rootPopoverButtonItem];
}

[detailViewController release];

}

、和都在我的类中声明splitViewController(我从苹果示例代码开始)。popoverControllerrootPopoverButtonItemRootViewController

代码构建得很好,但是当我调用该方法时,什么也没有发生。

4

1 回答 1

0

我最近也不得不学习如何做到这一点。我希望我的屏幕上有一个“关于”按钮,当用户单击该按钮时它会翻转到另一个视图,然后当他们单击“完成”按钮时翻转回我的原始视图。

我认为你过于复杂了。这是我必须调出关于视图的代码。

AboutViewController *aboutViewController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];

aboutViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:aboutViewController animated:YES]; //Show it!

显然,不要忘记在你的标题中导入它:#import <AboutViewController.h>

我恢复原始视图的代码(也就是隐藏关于视图)是:[self.parentViewController dismissModalViewControllerAnimated:YES];

于 2012-07-19T16:23:09.680 回答