UITableViewCell がその境界にクリッピングすることで、他のみんなと同じ問題を抱えています。他の誰かが正しく指摘したように、セルの contentView には新しいスーパービューがあります。だから私はこれをしました:
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"HomeTableViewCell";
ItemCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(!cell)
{
cell = [[ItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
//add views here as subviews to cell.contentView. Set them tags and retrieve later.
}
cell.clipsToBounds = FALSE;
cell.layer.masksToBounds = FALSE;
cell.contentView.clipsToBounds = FALSE;
cell.contentView.layer.masksToBounds = FALSE;
cell.contentView.superview.clipsToBounds = FALSE;
cell.contentView.superview.layer.masksToBounds = FALSE;
[self loadCell:cell inTable:tableView atIndexPath:indexPath];
return cell;
}
loadCell: inTable: atIndexPath:
タグによってセルのサブビューを取得し、適切なコンテンツをロードします。それはうまくいっています。clipToBounds
またはの他の言及はありませんlayer.masksToBounds
。BUT:選択したセルをリロードすると、一時的に境界にクリップされ、上記のコードにヒットして正しくなります。したがって、約1〜2秒間、セルが切り取られます。これが内部で起こっていることItemCell
です。このクラスを作成して、何がそのclipToBounds
プロパティを TRUE にするかを確認しました。
@implementation ItemCell
- (id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]))
{
[self addObserver:self forKeyPath:@"layer.masksToBounds" options:NSKeyValueObservingOptionNew context:nil];
[self addObserver:self forKeyPath:@"clipsToBounds" options:NSKeyValueObservingOptionNew context:nil];
}
return self;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
NSNumber *nr = [change objectForKey:@"new"];
if(nr.intValue)
{
self.clipsToBounds = FALSE; // STAY FALSE!!
self.layer.masksToBounds = FALSE;
}
}
TRUE になったときに FALSE にしても、クリップされた/クリップされていない間にギャップがあります。それはちょうど小さいです。iOS6では発生しませんでした。これは、プロパティが TRUE になったときのスタック トレースです。自動的に呼び出されるclipsToBounds
ことがわかります。CALayer setMasksToBounds
誰かが修正のアイデアを持っていますか?? ありがとうございました!