2013-02-09 78 views
0

我在我的應用程序中實現了拆分視圖。當我的應用程序啓動它顯示罰款。在ipad中的SplitView導航問題

馬西德威=萊夫特賽德視圖&的DetailView =首頁視圖

但我的主視圖還包含2表視圖。當我點擊表格視圖的任何一行時,詳細視圖(現在,班級視圖)沒有得到顯示

意思是我想按照主視圖所選表格行顯示多個細節視圖。

我的拆分視圖代碼如下:

// AppDelegate.h 

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

LeftViewController *masterViewController = [[LeftViewController alloc] initWithNibName:@"LeftViewController_iPad" bundle:nil] ; 
     UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController] ; 

     HomeViewController *detailViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController_iPad" bundle:nil]; 
     UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController]; 


     masterViewController.home_Detail = detailViewController; 

     self.splitViewController = [[UISplitViewController alloc] init] ; 
     self.splitViewController.delegate = detailViewController; 




     self.splitViewController.viewControllers=[NSArray arrayWithObjects:masterNavigationController,detailNavigationController, nil]; 

     self.window.rootViewController = self.splitViewController; 

     [self.window makeKeyAndVisible]; 
} 



//LeftView.m 

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


    [self.appDelegate.splitViewController viewWillDisappear:YES]; 
    NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] viewControllers]]; 

    [viewControllerArray removeAllObjects]; 

    if (tableView==tbl_class) 
    { 

     self.class_VC=[[Class_Vice_ViewController alloc]initWithNibName:@"Class_Vice_ViewController" bundle:nil]; 


     [[NSUserDefaults standardUserDefaults]setInteger:[[[classNames objectAtIndex:indexPath.row]valueForKey:@"class_id"]intValue] forKey:@"psel_class"]; 

     NSLog(@"%d",[[[classNames objectAtIndex:indexPath.row]valueForKey:@"class_id"]intValue]); 



     [viewControllerArray addObject:self.class_VC]; 
     self.appDelegate.splitViewController.delegate = self.class_VC; 

     [[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO]; 
     [class_VC viewWillAppear:YES]; 

    } 
} 

幫我解決這個問題

回答

1

的那一行是這樣一個在didSelectRowAtIndexPath方法:方法:

[self.appDelegate.splitViewController viewWillDisappear:YES]; 

我不知道你爲什麼要這樣做,但如果你刪除它,它應該工作。雖然這是很常見的重寫viewWillAppear中

[self.class_VC viewWillAppear:YES]; 

:你也不需要這條線和viewWillDisappear :,你幾乎從來沒有叫他們像你這樣做。