简体   繁体   English

将来自两个xib文件的两个tableview添加到主xib视图

[英]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 ? 如何从带有两个表控制器的两个xib文件向主xib视图添加两个tableview? is this possible? 这可能吗? Thanks in advance ? 提前致谢 ?

yes it is possible just add them as subviews programmatically in your main viewcontroller 是的,可以在您的主viewcontroller中以编程方式将它们添加为子视图

sample code: put this in your main view controller's viewdidload method 示例代码:将其放入主视图控制器的viewdidload方法中

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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