Ios 如何在滚动UITableViewCell时向其添加更多按钮?
当我们滚动(向左滑动)Ios 如何在滚动UITableViewCell时向其添加更多按钮?,ios,button,uitableview,ios7,Ios,Button,Uitableview,Ios7,当我们滚动(向左滑动)UITableViewCell时,它会显示一个删除按钮,但我想在上面添加其他按钮,我该怎么做 我想要的风格就像iOS 7中的系统邮件应用程序,UITableviewCell中有两个按钮,一个是删除按钮,另一个是更多按钮 请提出任何意见 感谢有可能,请按照以下步骤操作: 1) 委托函数canEditRowAtIndexPath应返回NO 2) 使用cellforrowatinexpath在UITableView中加载自定义单元格 3) 在自定义单元格中,显示两个或多个按钮并使
UITableViewCell
时,它会显示一个删除按钮,但我想在上面添加其他按钮,我该怎么做
我想要的风格就像iOS 7中的系统邮件应用程序,UITableviewCell中有两个按钮,一个是删除按钮,另一个是更多按钮
请提出任何意见
感谢有可能,请按照以下步骤操作: 1) 委托函数
canEditRowAtIndexPath
应返回NO
2) 使用cellforrowatinexpath
在UITableView中加载自定义单元格
3) 在自定义单元格中,显示两个或多个按钮并使用以下方式处理可见性:
[btn setHidden:NO];
希望它能给你一个想法,如何开始。这真的很容易,不要重新发明轮子使用此控件(自定义UITableViewCell)它是开源的,工作非常好 如果你不只是想把它放进去使用,那么至少你可以准确地阅读他们是如何做到的!
您可以使用此示例方法创建更多按钮 此链接示例非常有用,您可以创建“自定义更多”按钮 如中所述,您可以使用其他UITableView数据源/委托方法实现与Mail.app中相同的单元格布局
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath;
苹果公司也加入了他们自己的支持
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Edit" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
}];
editAction.backgroundColor = [UIColor blueColor];
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Delete" handler^(UITableViewRowAction *action, NSIndexPath *indexPath) {
}];
return @[deleteAction, editAction];
}
MSCMoreOptionTableViewCell使用方便,解决了我的问题。非常感谢!
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Edit" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
}];
editAction.backgroundColor = [UIColor blueColor];
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Delete" handler^(UITableViewRowAction *action, NSIndexPath *indexPath) {
}];
return @[deleteAction, editAction];
}