ios TableView那些事(三十一)UITableViewController ios8 删除时添加多个按钮
来源:互联网 发布:合川广电网络收费标准 编辑:程序博客网 时间:2024/06/06 20:57
ios 新的属性
typedef NS_ENUM(NSInteger, UITableViewRowActionStyle) {
UITableViewRowActionStyleDefault =0,
UITableViewRowActionStyleDestructive =UITableViewRowActionStyleDefault,
UITableViewRowActionStyleNormal
} NS_ENUM_AVAILABLE_IOS(8_0);
NS_CLASS_AVAILABLE_IOS(8_0)@interface UITableViewRowAction :NSObject <NSCopying>
+ (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style title:(NSString *)title handler:(void (^)(UITableViewRowAction *action, NSIndexPath *indexPath))handler;
/////////////////下面实现相关代码////////////////////////////
(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
returnYES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
if (editingStyle ==UITableViewCellEditingStyleDelete) {
[self.dataSourceremoveObjectAtIndex:indexPath.row];
[self.tableViewdeleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
//设置删除按钮
UITableViewRowAction *deleteRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDestructivetitle:@"删除"handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
[self.dataSourceremoveObjectAtIndex:indexPath.row];
[self.tableViewdeleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
}];
//设置收藏按钮
UITableViewRowAction *collectRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"收藏"handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
collectRowAction.backgroundColor = [UIColorgreenColor];
UIAlertView *alertView = [[UIAlertViewalloc]initWithTitle:@"收藏"message:@"收藏成功"delegate:selfcancelButtonTitle:@"确定"otherButtonTitles:nil,nil];
[alertView show];
}];
//设置置顶按钮
UITableViewRowAction *topRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"置顶"handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
[self.dataSourceexchangeObjectAtIndex:indexPath.rowwithObjectAtIndex:0];
NSIndexPath *firstIndexPath = [NSIndexPathindexPathForRow:0inSection:indexPath.section];
[tableView moveRowAtIndexPath:indexPathtoIndexPath:firstIndexPath];
}];
collectRowAction.backgroundEffect = [UIBlurEffecteffectWithStyle:UIBlurEffectStyleLight];
topRowAction.backgroundColor = [UIColorblueColor];
collectRowAction.backgroundColor = [UIColorgrayColor];
return @[deleteRowAction,collectRowAction,topRowAction];
}
- ios TableView那些事(三十一)UITableViewController ios8 删除时添加多个按钮
- ios TableView那些事(三十一)UITableViewController ios8 删除时添加多个按钮
- ios TableView那些事(三十)UITableViewController ios8 separatorEffect
- ios8 tableView设置滑动删除时显示多个按钮
- ios8 tableView设置滑动删除时显示多个按钮
- ios8 tableView设置滑动删除时显示多个按钮
- ios tableview 那些事(二十六)UITableViewController 多选操作
- ios TableView那些事(二十七)UITableViewController subclassView 不随着一起滚动
- ios TableView那些事(二十八)UITableViewController 设置滑动范围
- ios TableView那些事(二十 九)UITableViewController 粘合性
- ios tableView那些事(二)给tableView添加数据
- ios tableView那些事(二)给tableView添加数据
- tableview添加删除按钮
- ios tableview 删除按钮
- ios tableView那些事 (九) tableview的删除
- ios tableView那些事 (九) tableview的删除
- ios tableView那些事 (九) tableview的删除
- ios tableView那些事 (九) tableview的删除
- 在浏览器中输入网址按下回车后都发生了什么(整体概况)
- ubuntu重启网络
- elasticsearch customScoreQuery 实例
- python web应用开发中获取各种参数的方式
- java设计模式(三)
- ios TableView那些事(三十一)UITableViewController ios8 删除时添加多个按钮
- Jedis的Publish/Subscribe功能的运用
- JAVA开发环境的安装及设定
- Redis的pipeline方式
- 为Hadoop集群选择合适的硬件配置
- Android小知识点—ProgressBar、SharedPreferences
- STL底层数据结构实现
- std::string用法总结
- Android内存泄漏分析及调试