iPhone开发UITable内嵌不同风格Table


在iphone开发中使用Table的时候,由于Table有的风格UITableViewStylePlain或者UITableViewStyleGrouped一旦指定,便无法修改。但是在使用的过程中,总是会出现一些特殊的需求,他们要求可以同时使用不同的风格。

那么可以在制作table内嵌table吗。起初怀疑这样表格的滑动会出现问题,不过,在尝试之后发现,不但是可以实现,而且效果非常好。

至于代码中的delefat和datasource只要有指定tag来相应就可以了。 

我简单的在一个UITableViewController中的tableFooterView添加了一个group的table,各个功能都正常,没有出现问题。 

self.title = @"TableInTable";

UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 200) style:UITableViewStyleGrouped];

table.delegate = self;

table.dataSource = self;

// table.scrollEnabled = NO;

self.tableView.tableFooterView = table; 

delegatedataSource和当前的table一致,或者可以单独制定delegatehelper来实现数据源的处理,就可以实现一些比较变态的需求。 

简单效果如下

相关内容