如何更改方法中的detailViewController

发布于 2024-10-27 03:52:55 字数 1015 浏览 1 评论 0原文

我有一个正在执行很多功能的视图,当我完成时,我想更改为 newViewcontroller 。如果我在哪里从根视图执行此操作,我只需调用。

NewPageViewController *newDetailViewController = [[NewPageViewController alloc] initWithNibName:@"NewPageViewController" bundle:nil];
detailViewController = newDetailViewController;

但我需要从我的旧细节(右侧)开始,

我正在从右侧下载 splitview iPad 应用程序中的文件,下载文件后,我需要在我的方法中将 splitview 的右侧更改为新的 nib 文件,以便我可以打开和编辑该文件

有人能以正确的方式指出我吗?

现在我有:

-(void)changeView { 

    ListController *newDetailViewController = [[ListController alloc] initWithNibName:@"ListController"bundle:nil]

    NSArray *viewControllers = [NSArray arrayWithObjects:[splitViewController.viewControllers objectAtIndex:0], newDetailViewController, nil];

    splitViewController.viewControllers = viewControllers;
    [viewControllers release];

}

-(void)downloadfile {
 //I do all my work and get the file.
NSLog(@"I need to change views now.");


                [self changeView];

}

我没有收到任何错误,但右侧视图没有改变。

I have a view that is doing a lot of functions and when I get to the point that I am done I want to change to a newViewcontroller. if I where to do this from the rootview I just call.

NewPageViewController *newDetailViewController = [[NewPageViewController alloc] initWithNibName:@"NewPageViewController" bundle:nil];
detailViewController = newDetailViewController;

But I need to do it from my old detail (the right side)

I am downloading a file in a splitview iPad app from the right side and after the file is downloaded I need to in my method change the right side of the splitview to a new nib file so I can open and edit the file

Can someone point me in the right way.

Now I have :

-(void)changeView { 

    ListController *newDetailViewController = [[ListController alloc] initWithNibName:@"ListController"bundle:nil]

    NSArray *viewControllers = [NSArray arrayWithObjects:[splitViewController.viewControllers objectAtIndex:0], newDetailViewController, nil];

    splitViewController.viewControllers = viewControllers;
    [viewControllers release];

}

-(void)downloadfile {
 //I do all my work and get the file.
NSLog(@"I need to change views now.");


                [self changeView];

}

I don't get any errors but the right side view is not changing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冰雪梦之恋 2024-11-03 03:52:55

UISplitViewController 类上有一个 NSArray *viewControllers 属性。该数组中的第一项是您的主 VC,第二项是详细 VC。将此属性重新分配给包含相同主 VC 但新详细信息 VC 的新数组:

// don't forget to set the delegate of myNewDetailViewController appropriately!
myNewDetailViewController.delegate = ...

NSArray newVCs = [NSArray arrayWithObjects:[uiSplitVC.viewControllers objectAtIndex:0], myNewDetailViewController, nil];

uiSplitVC.viewControllers = newVCs;

UISplitViewController 的 API 参考: http://developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewController_class/Reference/Reference.html

注意:不要尝试更换主 VC - 它通常会以某种方式出现严重错误。 我尝试了很多方法来替换master,它总是以某种非常烦人的方式出错。不过替换细节VC就可以了!

There is an NSArray *viewControllers property on the UISplitViewController class. The first item in this array is your master VC, the second in the detail VC. Re-assign this property to a new array containing the same master VC but a new details VC:

// don't forget to set the delegate of myNewDetailViewController appropriately!
myNewDetailViewController.delegate = ...

NSArray newVCs = [NSArray arrayWithObjects:[uiSplitVC.viewControllers objectAtIndex:0], myNewDetailViewController, nil];

uiSplitVC.viewControllers = newVCs;

API ref for UISplitViewController: http://developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewController_class/Reference/Reference.html

N.B: do not try replacing the master VC -- it usually goes horribly wrong somehow. I tried many many ways of replacing the master, it always went wrong in some very annoying way. Replacing the detail VC is fine though!

不寐倦长更 2024-11-03 03:52:55

从 iOS8 开始,您可以在 UISplitViewController 上使用 -showDetailViewController:sender: 方法。请参阅 关于 UISplitViewController 的 Apple 文档

As of iOS8 you can use the -showDetailViewController:sender: method on the UISplitViewController. See the Apple docs on UISplitViewController.

鸩远一方 2024-11-03 03:52:55

正如 @chris 提到的,您可以使用 iOS 8 及更高版本的 UISplitViewController 的 Delegate,这是最好的方法。

 -(void)showDetailViewController:(UIViewController *)vc sender:(nullable id)sender NS_AVAILABLE_IOS(8_0);

As @chris mentioned you can the use Delegate of UISplitViewController for iOS 8 and above which is the best possible way.

 -(void)showDetailViewController:(UIViewController *)vc sender:(nullable id)sender NS_AVAILABLE_IOS(8_0);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文