【发布时间】:2015-09-23 15:47:16
【问题描述】:
我正在使用一个表格向用户显示图书目录。有些书是免费的,有些是高级书。我想根据用户的帐户状态(免费或高级)通知他们可以下载的书籍。尽管如此,用户仍然可以查看所有书籍(封面和摘要,但不能下载)。
为此,我正在尝试为免费用户调暗包含付费图书的单元格。
如何使单元格变暗?我已经尝试过以前的答案,例如How do I make a UITableViewCell appear disabled? 和UITableview: How to Disable Selection for Some Rows but Not Others,但没有运气。为什么 Alpha 版不起作用?
我的尝试朝着这个方向前进,但没有结果:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"SelectBookCell";
SelectBookCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[SelectBookCell alloc] init];
}
// Config images, title, author... information to show
Do stuff
// Dimmed premium books
if([[userAccount level] intValue] <= (NSInteger)[book objectForKey:@"level"])
{
[cell setAlpha: 0.2f];
cell.textLabel.alpha = 0.2f;
cell.detailTextLabel.alpha = 0.2f;
}
return cell;
}
【问题讨论】:
-
您的
SelectBookCell是UITableViewCell的自定义类吗?故事板中的主要内容?
标签: ios objective-c uitableview