Iphone 如何更改uitableview删除按钮文本
您好,我正在尝试更改当用户在我的tableview中滑动uitableviewcell时,删除按钮中显示的文本 我在另一个问题线程中看到了一个例子,它说使用这个tableview委托Iphone 如何更改uitableview删除按钮文本,iphone,ios,uitableview,delegates,Iphone,Ios,Uitableview,Delegates,您好,我正在尝试更改当用户在我的tableview中滑动uitableviewcell时,删除按钮中显示的文本 我在另一个问题线程中看到了一个例子,它说使用这个tableview委托 - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath 我的问题是,我如何使用这种方法。。我不知道如何使用它。只返回要显示
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
我的问题是,我如何使用这种方法。。我不知道如何使用它。只返回要显示的字符串,而不是删除。假设您希望为所有行显示“擦除”,则上述函数应包含:
return @"Erase";
阅读
此外,如果视图控制器不是UITableViewController,请在.h文件中添加UITableViewDelegate。也就是说,它可以是:
@interface SomeView : UIViewController <UITableViewDelegate>
在管理
UITableView
的控制器中,应该实现UITableviewDelegate
并在titleForDeleteConfirmationButtonFrrowatineXPath
方法中返回方法所需的标题
例如:
@interface CategoryAddViewController : UITableViewController
@end
@implementation CategoryAddViewController
// ...
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"Please don't delete me!";
}
@end
给你留下这样的东西:
在Swift中是相等的,只是方法签名不同
func tableView(tableView: UITableView, titleForDeleteConfirmationButtonForRowAtIndexPath indexPath: NSIndexPath) -> String? {
return "Erase"
}
Swift 4.2
override func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
return "Erase"
}
很好,但是为什么按钮的外观不再具有动画效果呢?添加后,删除按钮弹出,而不是动画!编辑:我的错,一定是sim卡故障。重新启动应用程序后,再次显示ok。@FaizanS。我也在调查这件事。难道没有办法仅仅改变财产吗?类似于<代码>self.tableView.deleteButton.name=@“删除”代码>而不是重写该方法?在编写本文时不是这样。在iOS SDK中,许多事情都是通过重写基本UI类的现有方法来实现的。快捷方式:
func tableView(tableView:UITableView,titleForDeleteConfirmationButtonFrrowatineXPath indexPath:NSIndexPath)->字符串{return“Remove Me”}
在这个答案中没有理由添加
。
override func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? {
return "Erase"
}