yourcell.mm中
-(void)willTransitionToState:(UITableViewCellStateMask)state
{[super willTransitionToState:state];
if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask)
{
//显示删除btn
}
else
{
}
}
viewheader
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (_Array.count == 0)
{
return nil;
}
else
{
UIImageView *image= [[[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, width, h)] autorelease];
image.backgroundColor = [UIColor blackcolor];
image.alpha = 0.9f;
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor whiteColor];
headerLabel.font = [UIFont boldSystemFontOfSize:16];
headerLabel.frame = CGRectMake(10.0, -10.0, 300.0, 45);
NSString *key = [_Array objectAtIndex:section];
if ([key isEqualToString:@"*"])
{
headerLabel.text = @"常用联系人";
}
else
{
headerLabel.text = [_Array objectAtIndex:section];
}
[image addSubview:headerLabel];
[headerLabel release];
return image;
}
}
本文介绍了一个自定义 UITableViewCell 类的方法 willTransitionToState:,用于在显示删除按钮时更新单元格的状态,并展示了如何根据 section 的不同为 UITableView 提供自定义的头部视图。
981

被折叠的 条评论
为什么被折叠?



