gpt4 book ai didi

iphone - 具有多个详细 View Controller 的 UISplitViewController

转载 作者:行者123 更新时间:2023-12-03 19:34:42 45 4
gpt4 key购买 nike

我正在制作一个 splitView 应用程序,我想要不同的详细 View Controller ,我进行了很多研究,发现使用苹果 MultipleDetailView Controller ,但它没有完全采用,所以任何人都可以使用它,所以有什么方法可以得到这个完成对所有人来说意味着不同的detailViewController。

最佳答案

嗨,Nazia,我刚刚从 http://kshitizghimire.com.np/uisplitviewcontroller-multipledetailviews-with-navigation-controller/ 找到了解决方案

你可以这样做:-

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

// Override point for customization after app launch.
self.splitViewController =[[UISplitViewController alloc]init];
self.rootViewController=[[RootViewController alloc]init];
self.detailViewController=[[FirstDetailViewController alloc]init];

UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController];

self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil];
self.splitViewController.delegate=self.detailViewController;

// Add the split view controller's view to the window and display.
[window addSubview:self.splitViewController.view];
[window makeKeyAndVisible];

return YES;
}

-(void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

/*
When a row is selected, set the detail view controller's detail item to the item associated with the selected row.
*/
NSUInteger row = indexPath.row;
[self.appDelegate.splitViewController viewWillDisappear:YES];
NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] viewControllers]];
[viewControllerArray removeLastObject];

if (row == 0) {
self.firstDetailViewController=[[[FirstDetailViewController alloc] init]autorelease];
[viewControllerArray addObject:self.firstDetailViewController];
self.appDelegate.splitViewController.delegate = self.firstDetailViewController;

}

if (row == 1) {
self.secondDetailViewController=[[[SecondDetailViewController alloc]init]autorelease];
[viewControllerArray addObject:self.secondDetailViewController];
self.appDelegate.splitViewController.delegate = self.secondDetailViewController;
}
[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO];

[self.appDelegate.splitViewController viewWillAppear:YES];
[viewControllerArray release];

}

您还可以查看这个演示 http://kshitizghimire.com.np/wp-content/uploads/2011/01/MultipleDetailViewsWithNavigator.zip

关于iphone - 具有多个详细 View Controller 的 UISplitViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15104404/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com