我有主视图控制器,它由几个按钮而不是 tableview 组成。我想在不同的按钮点击时打开不同的细节视图。
我在下面列出了代码,但这没有显示任何更改。
- (IBAction)NewEntryBtn:(UIButton *)sender
{
NSLog(@"new entry btn");
[self.appdelegate.splitViewController viewWillDisappear:YES];
NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[self.appdelegate.splitViewController.viewControllers objectAtIndex:1]viewControllers]];
[viewControllerArray removeLastObject];
self.secondVC=[[SecondDetailViewController alloc] init];
[viewControllerArray addObject:self.secondVC];
self.appdelegate.splitViewController.delegate = self.secondVC;
[[self.appdelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO];
[self.appdelegate.splitViewController viewWillAppear:YES];
}
- (IBAction)EditBtn:(UIButton *)sender
{
[self.appdelegate.splitViewController viewWillDisappear:YES];
NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[self.appdelegate.splitViewController.viewControllers objectAtIndex:1]viewControllers]];
[viewControllerArray removeLastObject];
self.secondVC=[[SecondDetailViewController alloc] init];
[viewControllerArray addObject:self.secondVC];
self.appdelegate.splitViewController.delegate = self.secondVC;
[[self.appdelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO];
[self.appdelegate.splitViewController viewWillAppear:YES];
}
有人可以建议更改吗?