私のコードの一部で、私は呼び出します
UITableViewCell *cell = (UITableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath];
セルの数を取得してから、アルファを .35 に変更します。これは機能し、細胞は色あせて見えます。
ただし、テーブルビューをスクロールすると、ウィンドウの外に移動してから戻るセルがフェードしなくなりました。これは、cellForRowAtIndexPath で無効な各行のアルファが .35 に設定されていても発生します。
cellForRowAtIndexPath でセルを返す直前にログに記録します
NSLog(@"%f", cell.alpha);
そして、それは.35を返します
しかし、スクロール後にセルがフェードしていませんか?表示される前に、アルファが魔法のように 1 に戻されたかのように見えます。
以下は、セクションクラスでの cellForRowAtIndexPath の実装です
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
if ([self disabled])
{
cell = [SectionedTableViewController tableView:tableView dequeueReusableCellWithIdentifier:@"CellDisabled" style:UITableViewCellStyleDefault];
cell.alpha = .35;
}
else
{
cell = [SectionedTableViewController tableView:tableView dequeueReusableCellWithIdentifier:@"CellEnabled" style:UITableViewCellStyleDefault];
cell.alpha = 1;
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//if-else block that only sets labels is here omitted
if (cell.textLabel.text == [[cs objectAtIndex:[self c]] type])
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
NSLog(@"%f", cell.alpha);
return cell;
}
そして、これらのセクションを調整するView Controllerは、次のようにそれらからセルを取得します:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Alpha: %f", [[[self sections] objectAtIndex:indexPath.section] tableView:tableView cellForRowAtIndexPath:indexPath].alpha);
return [[[self sections] objectAtIndex:indexPath.section] tableView:tableView cellForRowAtIndexPath:indexPath];
}
(そして NSLog は適切なアルファ値を記録しています)