在AppDelegate中,我们创建一个DetailView,然后在其之上显示一个loginView (UIModalPresentationFullScreen)。登录后,loginView将被解职。
DetailView有一个tableView,当您选择一个单元格/行并推送第二个detailView时。
到目前为止,我所做的是:在AppDelegate中我要求UI_USER_INTERFACE_IDIOM(),当成语是iPad时,我创建了一个splitView
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
FirstDetailViewController* fdvc = [[FirstDetailViewController alloc] initWithNibName:@"FirstDetailViewController" bundle:nil];
SecondDetailViewController* sdvc = [[SecondDetailViewController alloc] initWithNibName:@"SecondDetailViewController" bundle:nil];
UINavigationController* fdvcNavigationController = [[UINavigationController alloc] initWithRootViewController:fdvc];
UINavigationController* sdvcNavigationController = [[UINavigationController alloc] initWithRootViewController:sdvc];
splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:fdvcNavigationController, sdvcNavigationController, nil];登录后,我的LoginView被取消,我的LoginView将显示出来,左边是第一个DetailView (主人)。所以这里一切都很好。
现在我去FirstDetailViewController.m并搜索didSelectRowAtIndexPath,因为在那里我在"iPhone版本“中找到了pushView to SecondDetailViewController。
这就是我被困的地方。我已经尝试过几个SplitView教程,并阅读了其他有关splitview的问题。
但是我认为我的问题是某种“基本的”,因为我对编程/ iOS一般都是新手,而且不知道我的所有工具。
任何帮助都将不胜感激。
发布于 2013-04-02 13:10:52
在为表中的项目编写带有表视图和其他“显示”视图的应用程序时,我这样做是为了在这两种设备上工作:
// In App Delegate...
-(BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Create views
MyTableViewController* myTable = [[MyTableViewController alloc] init];
MyDetailViewController* myDetail = [[MyDetailViewController alloc] init];
UINavigationController* tableNav = [[UINavigationController alloc] initWithRootViewController:myTable];
UINavigationController* detailNav = [[UINavigationController alloc] initWithRootViewController:myDetail];
// Check device type
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
// Use a split view
UISplitViewController* splitView = [[UISplitViewController alloc] init];
split.viewControllers = @[tableNav, detailNav];
self.window.rootViewController = split;
} else {
// Use a single view for iPhone
self.window.rootViewController = tableNav;
}
}。
// In table view
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Check device type
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
// Tell the already visible detail view to load something
MyData* data = ...; \\ Get your thing to display however you want
[[NSNotificationCenter defaultCenter] postNotificationName:@"DisplayMyData" object:data];
} else {
// No detail controller exists yet, so create it
MyDetailViewController* myDetail = [[MyDetailViewController alloc] init];
[self.navigationController pushViewController:myDetail animated:YES];
[[NSNotificationCenter defaultCenter] postNotificationName:@"DisplayMyData" object:data];
}
}。
// In detail view
-(void) viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(displayData:) name:@"DisplayMyData" object:nil];
}
-(void) displayData:(NSNotification*)notify {
MyData* data = (MyData*) notify.object;
... // Display however...
}https://stackoverflow.com/questions/15760872
复制相似问题