UIContextualAction的标题未显示完整文本

时间:2019-03-08 03:46:47

标签: ios uitableviewrowaction uicontextualaction

我在表格视图单元格中创建了一个UIContextualAction,它显示了一个长文本,但是它工作不正确。标题显示带有以下内容的文本:文本示例...

如果我使用UITableViewRowAction在表视图单元格中滑动动作。标题在ios 10中显示完整,在ios 11+中出现错误

我用“ \ n”细分了文本行

- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *warningMessage = @"This is the title of UITablViewRowAction \nin table view cell.";
UITableViewRowAction *warningAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
                                                                         title:warningMessage
                                                                       handler:
                                       ^(UITableViewRowAction *action, NSIndexPath *indexPath){
    //do nothing
}];

return @[warningAction];

}

- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath  API_AVAILABLE(ios(11.0)) {
NSString *warningMessage = @"This is the title of UIContextualAction \nin table view cell.";

UIContextualAction *warningAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:warningMessage
                                                                          handler:
                                     ^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
    // action
}];

UISwipeActionsConfiguration *configuration = [UISwipeActionsConfiguration configurationWithActions:@[warningAction]];


configuration.performsFirstActionWithFullSwipe = NO;
return configuration;

}

这是图片。

有人可以帮助我解决这个问题吗?非常感谢。

ios10 ios11

0 个答案:

没有答案