我试图让我的应用在用户单击“提交”按钮后切换视图。
这是我到目前为止所拥有的:
视图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
(我从苹果示例代码开始)。popoverController
rootPopoverButtonItem
RootViewController
代码构建得很好,但是当我调用该方法时,什么也没有发生。