iOS-UIalertControllerポップアップ遅延(UIalertControllerポップアップが遅く、tableViewCellクリック時に背景色が変化)

1600 ワード

1.前言今日、tableViewセルに選択イベントを追加したときにUIalertControllerを呼び出した仲間がいましたが、UIalertControllerのポップアップが少し遅れていて、何が原因なのか分かりません.私も長い間探していました.私のテストを経て、私は解決できる方法を見つけました.具体的な理由はrunloopがUIをタイムリーに更新していないからだと思います.2.解決方法一:
[selfpresentViewController:AlertControlleranimated:YEScompletion:nil];
// :
dispatch_async(dispatch_get_main_queue(), ^{
[selfpresentViewController: AlertControlleranimated: YEScompletion:nil];
});

方法2:一部のパートナーはtableViewCellのselectionsStyleをU i t a b l e W i w CellSelectionsStyleNoneに設定し、この設定を削除するだけでいいか、U i t a b l eViewCellSelectionsStyleDefaultに設定すればいい.
3.第2の修正方法について説明する.ここでは、cellに背景色が選択されているため、cellのコントロールの色に影響を与えるselectionStyle=U i t a b l e W i e w CellSelectionStyleNoneを設定するパートナーが多いと思います.このように設定することができます.まずcellの選択背景を以下のように設定できます.
UIView *cellBlack = [[UIView alloc] initWithFrame:cell.frame];
cellBlack.backgroundColor = [UIColor clearColor];
cell.selectedBackgroundView = cellBlack;
、次にcellの中に
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
UIColor *originColor = self.leftMessage.backView.backgroundColor;
[super setSelected:selected animated:animated];
self.leftMessage.backView.backgroundColor = originColor;
}
を設定します.
  • (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { UIColor *originColor = self.leftMessage.backView.backgroundColor; [super setHighlighted:highlighted animated:animated]; self.leftMessage.backView.backgroundColor = originColor; }

  • 転載先:http://blog.csdn.net/u014220518/article/details/55095598