【发布时间】:2023-03-15 18:45:02
【问题描述】:
从网上下载了示例聊天演示应用程序。我必须更改两个自定义单元格的布局方向(左侧传入消息,右侧传出消息)。截至目前,传入和传出单元格布局方向均保留。所以,我用 UISemanticContentAttributeForceRightToLeft 改变了传出单元格的方向。
左侧的传入消息,右侧的传出消息都可以正常工作。但是自定义tableview 单元格在重新加载表格视图时会闪烁。
请在不更改传出消息单元的设计的情况下帮助我。
【问题讨论】:
-
请在此处分享您的某种代码,以便更好地理解您的问题。
-
输出单元格:dispatch_async(dispatch_get_main_queue(), ^{ cell.contentView.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft; });
-
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"MovieCell"; MoviesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; if (indexPath.row%2 == 0) { // 偶数行 dispatch_async(dispatch_get_main_queue(), ^{ cell.contentView.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft; }); } 返回单元格; }
-
@HardikS 你明白我的意思了吗?
标签: ios objective-c swift uitableview