【发布时间】:2015-10-01 15:28:37
【问题描述】:
按照这个答案Custom UITableViewCell selection style? 中关于如何为UITableViewCell 制作自定义选择样式的建议,我执行了以下操作。
首先,在我的自定义视图控制器中,它有一个 UITableView 作为属性并用作它的数据源和委托,我有以下内容:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//UITableViewCell *cell;
NavTableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
那么这就是我的整个自定义 UITableViewCell:
#import "NavTableViewCell.h"
@implementation NavTableViewCell
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
if(highlighted){
self.contentView.alpha = .5;
}else{
self.contentView.alpha = 1;
}
}
@end
我也尝试将代码放入setSelected。在这两种情况下,我都没有看到我选择/突出显示的表格视图单元格有任何变化。我试过改变它的颜色和改变它里面标签的颜色,但根本没有改变。我还尝试过查看单元格的各种选择样式,但就看到我的自定义而言,一切都无济于事。
我做错了什么?
【问题讨论】:
标签: ios objective-c uitableview