单击 editButtonItem 时,不显示红色删除图标

发布于 2024-08-18 02:59:31 字数 853 浏览 6 评论 0原文

我现在正在写一个iPhone IM聊天窗口。

您知道,如果 UITableviewController 中的 nagviationItem.rightBarItem 设置为 editButtonItem,则单击编辑按钮,然后每行都会显示一个红色删除图标, 如此处所示

问题是,我有一个 UIViewController 而不是 UITableViewController:

@interface ChatUIViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{
    UITableView *table;
    UITextField *textField;

}

并且我做了同样的设置 editButtonItem:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.rightBarButtonItem = self.editButtonItem;

}

当我单击编辑按钮时, 红色删除图标将不会显示

如何使我的 ChatUIViewController 中显示红色删除图标?

预先感谢任何可能提供帮助的人。 迈克尔

I am writing an IPhone IM chat window now.

You know if the nagviationItem.rightBarItem in an UITableviewController is set to editButtonItem, you click the edit button then a red delete icon is shown to every single row, like shown here.

The problem is, I have a UIViewController instead of a UITableViewController:

@interface ChatUIViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{
    UITableView *table;
    UITextField *textField;

}

and i did same to set editButtonItem:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.rightBarButtonItem = self.editButtonItem;

}

when i click the edit button, the red delete icon will not show.

How can I make the red delete icon shown in my ChatUIViewController?

Thanks in advance to anyone who might help.
Michael

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独木成林 2024-08-25 02:59:31

将以下方法添加到表视图委托类中:

- (void) setEditing:(BOOL)editing animated:(BOOL)animated {
    [super setEditing:editing animated:animated];
    [self.tableView setEditing:editing animated:animated];
    if (editing) {
        // you might disable other widgets here... (optional)
    } else {
        // re-enable disabled widgets (optional)
    }
}

Add the following method to your table view delegate class:

- (void) setEditing:(BOOL)editing animated:(BOOL)animated {
    [super setEditing:editing animated:animated];
    [self.tableView setEditing:editing animated:animated];
    if (editing) {
        // you might disable other widgets here... (optional)
    } else {
        // re-enable disabled widgets (optional)
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文