特殊案例:UITableView、UICollectionView

5、deeplink customerservice no permission
APP拉起微信客服功能

uniapp跳转微信客服报错 (deeplink customerservice no permission)
https://blog.csdn.net/PlutoZML/article/details/120783101
https://ask.dcloud.net.cn/question/135519

4.cellForItemAtIndexPath 返回空

  1. 动画需要获取当前的 Cell ,下面的调用在 viewDidLoad 中,有时候返回 nil,有时候成功。
    UICollectionView cell = (UICollectionView)[self.collectionView cellForItemAtIndexPath:indexPath];

简单的解决方法,是在调用之前添加:
[self.collectionView layoutIfNeeded];

原因是,根据苹果开发者文档:
UICollectionView如果 cell 不是 visible 的 或者 indexPath 超过有效范围,就返回 nil。

在 iOS 10 上 还有一种解法, 但这种就牺牲了性能:
[self.collectionVew setPrefetchingEnabled: NO];

引用:https://yiweifen.com/html/news/WaiYu/13536.html
https://blog.csdn.net/weixin_30462049/article/details/94863575

  1. 点击cell reload oldIndex
    [collectionView reloadItemsAtIndexPaths:@[oldIndexPath,indexPath]];
    如果oldIndex和indexPath,会有显示bug
    if (oldIndex != indexPath.row) {
    [collectionView reloadItemsAtIndexPaths:@[oldIndexPath,indexPath]];
    }



3. UITableViewCell 上的按钮 点击无响应(这个问题怪异)
解决方案:添加背景色,

self.contentView.backgroundColor = [UIColor xxx];
self.backgroundColor = [UIColor xxx];



2. UITableView 头部有偏移距离
解决方案:添加表头,高度为0

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SSWIDTH, 1)];
self.ttableView.tableHeaderView = view;



1、UITableView,UICollectionView 判断reloadData结束

UITableView reloadData
//方法1:
[self.tableView reloadData];
[self.tableView layoutIfNeeded];
//刷新完成,其他操作,有时候这个方法无效

//方法2:
[self.tableView reloadData];
[self.tableView layoutIfNeeded];
dispatch_async(dispatch_get_main_queue(),^{
 //刷新完成,其他操作
});
UICollectionView reloadData
//方法1:刷新完成,其他操作,有时候这个方法无效
[self.collectionView reloadData];
[self.collectionView layoutIfNeeded];

//方法2:
[self.collectionView reloadData];
[self.collectionView layoutIfNeeded];
dispatch_async(dispatch_get_main_queue(),^{
 //刷新完成,其他操作
});

//方法3:
[self.collectionView performBatchUpdates:^{
        //刷新操作
    } completion:^(BOOL finished) {
        //刷新完成,其他操作
    }];
}];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容