简体   繁体   中英

Add two tableviews from two xib file to main xib view

How to add two tableview from two xib file with two table controller to main xib view ? is this possible? Thanks in advance ?

yes it is possible just add them as subviews programmatically in your main viewcontroller

sample code: put this in your main view controller's viewdidload method

    UITableView *tableview1 = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320,200) style:UITableViewStylePlain];
    tableview1.delegate = self;
    tableview1.dataSource = self;
    tableview1.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.6];
    [self.view addSubview:tableview1];

    UITableView *tableview2 = [[UITableView alloc] initWithFrame:CGRectMake(0, 200, 320,200) style:UITableViewStylePlain];
    tableview2.delegate = self;
    tableview2.dataSource = self;
    tableview2.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.6];
    [self.view addSubview:tableview2];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM