在我的应用程序中,我有3个类别(部分),而在每个类别中,我有3个条目(行)。我已经通过使用分组样式UITableview来实现它。
但它的分组方式不适合我的应用程序流。
如何自定义UITableview节?
实际上,我想要3个区块类型的部分,而且我应该能够选择整个块,而不是单独的子类别(即行)。当用户选择整个块时,将出现新的控制器。他们的方法是:-didSelectSectionAtIndexpath吗?这样整个动作就可以在整个部分上执行?
发布于 2014-02-03 11:38:09
请你对这个问题再详细说明一下好吗?一旦这些部分被触摸,你想显示什么??与该部分相关的三个项目的视图控制器?
发布于 2014-02-03 11:38:07
您可以创建自定义页眉视图,如下所示,并以相同的方式设置页脚
用于报头
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 18)];
/* Create custom view to display section header... */
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, tableView.frame.size.width, 18)];
[label setFont:[UIFont boldSystemFontOfSize:12]];
NSString *string =[list objectAtIndex:section];
/* Section header is in 0th index... */
[label setText:string];
[view addSubview:label];
[view setBackgroundColor:[UIColor colorWithRed:166/255.0 green:177/255.0 blue:186/255.0 alpha:1.0]]; //your background color...
return view;}
页脚
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section; // custom view for footer. will be adjusted to default or specified footer height您需要以这样的方式创建这两个视图,使其看起来是一个整体(根据您的UI需求)。
发布于 2014-02-03 11:28:35
没有didSelectSectionAtIndexpath方法,但你可以做一些即兴创作。您可以向整个标题部分添加一个按钮,然后在此按钮单击事件上显示新的控制器。
还在didselectrowatindexpath上调用相同的新控制器。
现在将cell.selectionStyle = UITableViewCellSelectionStyleNone;设置为cellForRowAtIndexPath。这将给用户的印象是,他实际上是在选择整个区块。
您还必须创建UI智能,以使标题和行看起来像一个部分。
https://stackoverflow.com/questions/21525899
复制相似问题