iOS 9 的 可以通过下面的代码拿到,self 是 UITableViewCell,但是9以下就不行了,而且这么拿 也不靠谱,有大神知道有什么更好的办法能过拿到这个按钮对象吗?
for (UIView *subView in self.subviews) {
if ([NSStringFromClass([subView class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"]) {
UIView *view = ((UIView *)[subView.subviews firstObject]);
}
}
Traversing subviews may not necessarily get the view you want, because sometimes, what you see is not necessarily a view, it may be a layer, or it may be just a small area drawn in the view.
If you want to get this view, all you can think of is customizing its text or style, and adding some touch events.
It is easy to modify the text and background color and add clicks. If you want to deeply customize this view, it may be better to implement one yourself.
Why don’t you tell me what you want to do after you get this? Maybe we can change our thinking.
Customized "Edit" and "Delete" button implementation
tableView
的一个delegate
:You probably want to modify the text on the button, then you can call the following API:
It allows you to customize multiple return buttons, and you can set a red button and multiple gray buttons.
You can refer to the following links:
http://www.cnblogs.com/scaptain/p/3950123.html
http://blog.csdn.net/lcl130/article/details/42131821