iOS-UIAlertController弹出延迟(UIAlertController弹出缓慢,tableViewCell点击时背景颜色改变)
来源:互联网 发布:淘宝饰品店店铺介绍 编辑:程序博客网 时间:2024/04/30 22:48
1.前言
今天有个小伙伴问我,他在给tableViewCell添加选中事件的时候,调用UIAlertController,但是UIAlertController弹出有点延迟,不知道什么原因,我也找了好久。
经过我测试我发现了一种方法可以解决;具体原因我认为是runloop没有及时更新UI。
2.解决办法
方法一:
[selfpresentViewController:AlertControlleranimated:YEScompletion:nil];
改为下面的方法:dispatch_async(dispatch_get_main_queue(), ^{
[selfpresentViewController: AlertControlleranimated:YEScompletion:nil];
});
方法二:
一部分小伙伴把tableViewCell的selectionStyle设成了UITableViewCellSelectionStyleNone,只需要将这个设置去掉就好或者设置成UITableViewCellSelectionStyleDefault就好;
3.说明
针对第二种修改方法;
在这我就多说一下,很多小伙伴设置selectionStyle=UITableViewCellSelectionStyleNone,是因为cell有个选中背景颜色,会影响cell上面控件的颜色。我们可以这样设置,可以先设置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;}
2 0
- iOS-UIAlertController弹出延迟(UIAlertController弹出缓慢,tableViewCell点击时背景颜色改变)
- TableViewCell 上 UIAlertController 延迟弹出问题
- iOS点击UITableView的cell,弹出UIAlertController有时会出现延迟
- iOS UIAlertController 弹出框控制器
- iOS开发-------UIAlertController(弹出视图控制器)
- 关于iOS中的弹出窗口----UIAlertController
- UIAlertController 弹出延时
- iOS UIAlertController修改title颜色
- iOS,UIAlertController
- ios UIAlertController
- iOS UIAlertController
- iOS - UIAlertController
- iOS UIAlertController
- ios UIAlertController
- iOS UIAlertController
- iOS UIAlertController
- [iOS]UIAlertController各标签属性的改变
- [iOS]UIAlertController各标签属性的改变
- Android 手机获取手机号实现方法
- Java泛型
- 让我怎能过大年
- Linux/Windows ssh公私钥访问
- Android Camera中我遇到的巨坑
- iOS-UIAlertController弹出延迟(UIAlertController弹出缓慢,tableViewCell点击时背景颜色改变)
- linux shell中利用awk获取关键字符的用法,实例说明。
- Javase笔记之集合类
- java食品管理系统(ArrayList的使用)
- iOS开发-读取“健康”中的步数和步行+跑步距离
- 多线程买票
- LeetCode Shell
- scp命令
- 算法学习(九)贪婪技术