iOS开发:解决一个循环引用的bug

西门桃桃 2020-07-07 PM 1647℃ 0条

self持有了tableView,tableView持有了cell,cell中的一个block持有了self,然后就循环引用了。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
KKBVideoClipsCell *cell = [tableView dequeueReusableCellWithIdentifier:KKBVideoClipsCell.className forIndexPath:indexPath];
cell.itemModel = self.dataList[indexPath.row];
@weakify(self);
cell.didClickSlogan = ^(NSString *url) {
    @strongify(self);
    KKBVideoClipsWebController *webController = [[KKBVideoClipsWebController alloc] init];
    webController.url = url;
    webController.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:webController animated:YES completion:nil];
};
return cell;
}
标签: iOS, 循环引用

非特殊说明,本博所有文章均为博主原创。

评论啦~