使用 MGSplitView 控制器更改视图
在 io 正在创建的应用程序中,我有一个 UISplitView 控制器 MGSplitViewController 的自定义副本。我已将其实现到我的项目中,该项目从苹果的 MultipleDetailViews 示例代码开始。
我遇到了一个问题,我似乎无法在视图控制器之间切换。当我推送表格视图单元格时,详细视图控制器应该根据分配的笔尖进行更改,但这不会发生。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
/*
Create and configure a new detail view controller appropriate for the selection.
*/
NSUInteger row = indexPath.row;
UIViewController *detailViewController = nil;
if (row == 0) {
FirstDetailViewController *newDetailViewController = [[FirstDetailViewController alloc] initWithNibName:@"FirstDetailView" bundle:nil];
detailViewController = newDetailViewController;
}
if (row == 1) {
SecondDetailViewController *newDetailViewController = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailView" 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];
[detailViewController release];
通常,此代码足以更改原始多个详细视图代码中的视图。
有人遇到过类似的问题吗?有什么想法吗?
In the app that io am creating, i have a custom copy of UISplitView Controller, MGSplitViewController. I have implemented it into my project which started off with the MultipleDetailViews sample code from apple.
I have come across a problem where i cant seem to switch between viewcontrollers. When i push the tableview cells, the detailview controller should change according the the nib assigned, however that doesn't happen.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
/*
Create and configure a new detail view controller appropriate for the selection.
*/
NSUInteger row = indexPath.row;
UIViewController *detailViewController = nil;
if (row == 0) {
FirstDetailViewController *newDetailViewController = [[FirstDetailViewController alloc] initWithNibName:@"FirstDetailView" bundle:nil];
detailViewController = newDetailViewController;
}
if (row == 1) {
SecondDetailViewController *newDetailViewController = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailView" 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];
[detailViewController release];
Normally this code would be enough to change the views in the original Multiple Detail View code.
has anyone run into a similar problem? any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只是创建新的视图控制器。您没有将它们添加到任何地方。您可以使用其
viewControllers
属性将视图控制器添加到拆分视图控制器。编辑:我使用过
MGSplitViewController
,但我从未尝试过像这样更改详细视图。我刚刚将新的详细视图控制器推送到导航控制器上。是否有特定原因想要完全更改详细视图控制器?You're just creating new view controllers. You're not adding them anywhere. You add view controllers to the split view controller by using its
viewControllers
property.EDIT: I've used
MGSplitViewController
, but I never tried to change the detail view like that. I just pushed the new detail view controller onto the navigation controller. Is there a specific reason for wanting to change the detail view controller entirely?