// 自動進入編輯模式,出現左滑效果
- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
// 回調方法里寫點擊事件
UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:(UITableViewRowActionStyleNormal) title:@"樂呵拉赫" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"xixi");
}];
UITableViewRowAction *rowAction2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"樂呵你妹" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"doubi");
}];
UITableViewRowAction *rowAction3 = [UITableViewRowAction rowActionWithStyle:(UITableViewRowActionStyleDefault) title:@"刪除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"刪了");
}];
UITableViewRowAction *rowAction4 = [UITableViewRowAction rowActionWithStyle:(UITableViewRowActionStyleDestructive) title:@"111" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"222");
}];
rowAction.backgroundColor = [UIColor redColor];
rowAction2.backgroundColor = [UIColor greenColor];
NSArray *array = @[rowAction,rowAction3,rowAction2,rowAction4];
return array;
}
iOS8左滑出現三個按鈕
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
推薦閱讀更多精彩內容
- 大家都知道iOS8系統新添加了個方法,- (nullable NSArray)tableView:(UITable...
- 之前想在cell左滑的時候添加更多的按鈕而不是只有‘刪除’按鈕如下所示,貌似不是一件簡單的事。但是現在只要實現幾個...