在iPad纵向方向上的iOS6上,在btn上单击RootViewController更改DetailViewController失败 [英] Changing DetailViewController on btn click in RootViewController fails on iOS6 in iPad Portrait Orientation

查看:103
本文介绍了在iPad纵向方向上的iOS6上,在btn上单击RootViewController更改DetailViewController失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的应用程序从iOS3.2移植到iOS6。在iPad上,我使用SplitViewController。

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

在RootViewController中,我有一个表视图。如果用户单击表视图中的行,我将更改DetailViewController。

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

执行此操作的代码是:

   - (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.

在纵向方向上,DetailViewController不会更改。该行被选中并且上面的代码正在运行但是没有看到DetailViewController更改。 (我正在使用Xcode 4.5)

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)

非常感谢您的帮助!

谢谢。

推荐答案

我看到的一些你可能想看的东西:1)为什么你不使用didSelectRowAtIndexPath而不是这个自定义方法? 2)看来你在viewControllers上调用了一个版本...... ARC消除了释放的需要。 3)在第一行你有self.parentViewController.parentViewController??? 4)你正在使用带有笔尖的init ...为什么不使用storyboard和segues?
我带来了一些这些因为我正在完成同样的项目......将最初为iOS3编写的应用程序移动到iOS6。我几乎不得不重写整个应用程序,因为这已经发生了很大变化。

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.

这篇关于在iPad纵向方向上的iOS6上,在btn上单击RootViewController更改DetailViewController失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆