Changing DetailViewController on btn click in RootViewController fails on iOS6 in iPad Portrait Orientation

女生的网名这么多〃 提交于 2019-12-25 00:14:50

问题


I am porting my App from iOS3.2 to iOS6. On iPad, I use the SplitViewController.

In the RootViewController, I have got a table view. If the user clicks on a row in the table view, I change the DetailViewController.

The code doing this is:

   - (void)setDetailViewAuthorPage { 

UISplitViewController *splitViewController = 
(UISplitViewController *)self.parentViewController.parentViewController;

UIViewController *detail = 
[splitViewController.viewControllers objectAtIndex:1];

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

NSArray *viewControllers = 
[[NSArray alloc] 
 initWithObjects:self.navigationController, 
 detailViewController, 
 nil];

splitViewController.viewControllers = viewControllers;

[detailViewController viewWillAppear:YES];

[viewControllers release];

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

[detailViewController 
 showRootPopoverButtonItem:self.rootPopoverButtonItem
 root:self];

In the landscape orientation, this code works fine.

In the portrait orientation, the DetailViewController is not changed. The row gets selected and the code above is running but no DetailViewController change can be seen. (I am using the Xcode 4.5)

You help is much appreciated!

Thank you.


回答1:


A couple of things that I see that you might want to look at: 1) Why aren't you using didSelectRowAtIndexPath instead of this custom method? 2) It appears you are calling a release on your viewControllers... ARC eliminates the need for releasing. 3) in the first line you have "self.parentViewController.parentViewController" ??? 4) You are using an init with nib... why not use storyboard and segues? I bring some of these up because I am finishing up the same kind of project... moving an app that was originally written for iOS3 to iOS6. I have practically had to rewrite the entire app because that much has changed.



来源:https://stackoverflow.com/questions/12997051/changing-detailviewcontroller-on-btn-click-in-rootviewcontroller-fails-on-ios6-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!