發(fā)現(xiàn)問題
同事在看我代碼的時候發(fā)現(xiàn)在點(diǎn)擊Cell修改性別的時候,發(fā)現(xiàn)AlterViewcontroller沒有彈出,需要多次點(diǎn)擊.然后我在測試的時候偶然返現(xiàn)并不沒有彈出.而是過了一會才彈出.那為什么彈出比較慢呢.
我之前的猜測是由于剛點(diǎn)過了一次,在此進(jìn)行點(diǎn)擊的時候,需要對之前AlterViewController進(jìn)行銷毀等操作.所以導(dǎo)致彈出比較慢(當(dāng)然這個比較慢并不是第一次點(diǎn)擊的)
在網(wǎng)上查到的問題都是說runloop沒有及時更新UI
解決方方法
解決方法有兩種我都進(jìn)行過測試了.
第一種
[self presentViewController:alertController animated:YES completion:nil];
將上面代碼改成下面這種
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:alertController animated:YES completion:nil];
});
第二種
不設(shè)置TableViewCell的selectionStyle 或者設(shè)置成默認(rèn)的UITableViewCellSelectionStyleDefault
當(dāng)然有些人認(rèn)為cell的選中效果比較難看
那么可以在cell中設(shè)置cell的選中BackGroudView
[self setSelectedBackgroundView:view];
網(wǎng)上有人的人還修改下面的方法,我就使用了 上面的就可以了
- (void)setSelected:(BOOL)selected animated:(BOOL)animated;
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;