UISplitViewController with multiple Detail View Controller

前端 未结 1 353
-上瘾入骨i
-上瘾入骨i 2020-12-30 16:52

I am making a splitView application and i want different detail view controllers for all i have studies a lot found that use apples MultipleDetailView Controllers but it is

相关标签:
1条回答
  • 2020-12-30 17:43

    hi Nazia i just found solution From http://kshitizghimire.com.np/uisplitviewcontroller-multipledetailviews-with-navigation-controller/

    you can do like:-

    - (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];
    
     }
    

    you can also check this Demo http://kshitizghimire.com.np/wp-content/uploads/2011/01/MultipleDetailViewsWithNavigator.zip

    0 讨论(0)
提交回复
热议问题