除了使用弹出框和选择之外,我们如何更改 UISplitViewController 中的视图?

发布于 2024-08-28 00:50:32 字数 1567 浏览 3 评论 0原文

我已经使用 UISplitViewController 完成了一个示例应用程序,研究了他们提供的示例。我创建了三个详细视图,并将它们配置为通过默认方式进行更改。可以在横向使用左/主视图,也可以在纵向使用弹出框。

现在我尝试通过在每个视图中向左/向右滑动来从当前视图移动到另一个视图(上一个/下一个)。为此,我所做的只是在 RootViewController 中创建一个函数。我从 RootViewController 中复制粘贴了与弹出框使用的表格行选择相同的代码。我从当前视图的控制器调用此函数,并从当前视图传递视图的相应索引(接下来要显示)。正在调用函数,但什么也没有发生。

请帮助我,或者除了这个复杂的步骤之外还有其他方法吗?我给出了我用来改变视图的功能。

 - (void) rearrangeViews:(int)viewRow
{
UIViewController <SubstitutableDetailViewController> *detailViewController = nil;

if (viewRow == 0) {
    DetailViewController *newDetailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
    detailViewController = newDetailViewController;
}

if (viewRow == 1) {
    SecondDetailViewController *newDetailViewController = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailView" bundle:nil];
    detailViewController = newDetailViewController;
}

if (viewRow == 2) {
    ThirdDetailViewController *newDetailViewController = [[ThirdDetailViewController alloc] initWithNibName:@"ThirdDetailView" bundle:nil];
    detailViewController = newDetailViewController;
}

// Update the split view controller's view controllers array.
NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil];
splitViewController.viewControllers = viewControllers;
[viewControllers release];

if (rootPopoverButtonItem != nil) {
    [detailViewController showRootPopoverButtonItem:self.rootPopoverButtonItem];
}

[detailViewController release]; 

}

I have done a sample app with UISplitViewController studying the example they have provided. I have created three detailviews and have configured them to change by the default means. Either using the left/master view in landscape AND using the popover in the portrait orientation.

Now I am trying to move to another view(previous/next) from the currentView by using left/right swipe in each view. For that, what I did was just created a function in the RootViewController. I copy-pasted the same code as that of the tablerow selection used by the popover from the RootViewController. I am calling this function from my current view's controller and is passing the respective index of the view(to be displayed next) from the current view. Function is being called but nothing is happening.

Plz help me OR is anyother way to do it other than this complex step? I am giving the function that I used to change the view.

 - (void) rearrangeViews:(int)viewRow
{
UIViewController <SubstitutableDetailViewController> *detailViewController = nil;

if (viewRow == 0) {
    DetailViewController *newDetailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
    detailViewController = newDetailViewController;
}

if (viewRow == 1) {
    SecondDetailViewController *newDetailViewController = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailView" bundle:nil];
    detailViewController = newDetailViewController;
}

if (viewRow == 2) {
    ThirdDetailViewController *newDetailViewController = [[ThirdDetailViewController alloc] initWithNibName:@"ThirdDetailView" bundle:nil];
    detailViewController = newDetailViewController;
}

// Update the split view controller's view controllers array.
NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil];
splitViewController.viewControllers = viewControllers;
[viewControllers release];

if (rootPopoverButtonItem != nil) {
    [detailViewController showRootPopoverButtonItem:self.rootPopoverButtonItem];
}

[detailViewController release]; 

}

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

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

发布评论

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

评论(1

吃颗糖壮壮胆 2024-09-04 00:50:32

我用谷歌搜索并找到了一个不错的方法。他们在详细视图上使用 UINavigationController 来推送新视图。您可以在您的项目中使用相同的解决方案。

http://www.cimgf.com/2010/05/ 24/修复uisplitviewcontroller模板/

I have googled and found a nice approach. They use a UINavigationController on the detail view to push new views. You could use this same solution for your project.

http://www.cimgf.com/2010/05/24/fixing-the-uisplitviewcontroller-template/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文