【发布时间】:2011-05-15 16:40:03
【问题描述】:
我对 UITableViewCell 进行了子类化。我想要的是当我单击单元格时,我在单元格的底部添加了一个 UIView 并相应地调整了单元格的高度。这是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCell* cell = (MyCell *) [self.table cellForRowAtIndexPath:indexPath];
UIView * options = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.size.height - 27, cell.frame.size.width, 27)];
UIButton* button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[options addSubview:button1];
UIButton* button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[options addSubview:button2];
UIButton* button3 = [UIButton buttonWithType:UIButtonTypeCustom];
[options addSubview:button3];
//did some layout calculation here to position the button
[cell addSubview:options];
}
这是一个说明问题的video
我还尝试将我的单元格的附件视图从我的自定义 UIButton 更改为常规 UITableViewCellAccessoryDisclosure,但它没有工作
MyCell * cell = (MyCell *)[self.table cellForRowAtIndexPath:temp];
[cell.accessoryView removeFromSuperview];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
如果您对我想要做什么感到好奇,我正在尝试创建一个 tweetbot uitableviewcell,您可以在其中按下单元格/行,它会为您提供其他选项(转推等),并且还会显示动画。
【问题讨论】:
-
不确定为什么将其声明为重复...该问题并未询问有关将子视图添加到单元格并调整其大小
-
在我看来,这个问题的主体可以回答你的问题。但是,我可能是错的,这就是自动生成的注释显示“可能”的原因。
标签: iphone objective-c ipad uitableview