如何在编辑时更改iPhone UITableView删除按钮标题
-
05-07-2019 - |
题
我需要更改在将编辑设置为 YES
后尝试从 UITableView
中删除行时出现的默认删除按钮的标题。
解决方案
您可以在UITableView委托方法
中更改它- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
其他提示
夫特
将此方法添加到 UITableView
委托(可能是您的视图控制器)。
func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAtIndexPath indexPath: NSIndexPath) -> String? {
return "Erase"
}
这使按钮说“擦除”。但你可以使用你想要的任何字符串。
我更全面的答案是此处。
Swift 3
差别很小_
func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
return "Erase"
}
对于那些已经实现了方法'titleForDeleteConfirmationButtonForRowAtIndexPath'并且仍然看到相同'删除'文字的人
尝试使用自动完成功能从头开始从输入 ,因为我复制了某人,并且它有一些不同的旧标记,并且没有被调用!
不隶属于 StackOverflow