ios - 方法不是在 iPhone 中调用而是在 iOS 模拟器中调用

标签 ios objective-c iphone

我很沮丧地知道一个方法在 iOS 模拟器中工作正常但在我的 iPhone 中不起作用。我使用的是 iPhone 4S。

我想做的是,我想在滑动时添加“编辑”按钮而不是“删除”按钮。我正在为此使用以下代码-

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
return YES;
}


- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath{

}

- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{

UITableViewRowAction *edit = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
                                                                title:@"Edit"
                                                              handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
                                                                  // Open Edit Screen
                                                                  isEdited = YES;
                                                                  if (isSearchResult) {
                                                                      editArray = [NSMutableArray arrayWithObject:[searchResults objectAtIndex:indexPath.row]];
                                                                  }
                                                                  else{
                                                                      editArray = [NSMutableArray arrayWithObject:[soArray objectAtIndex:indexPath.row]];
                                                                  }

                                                                  [self performSegueWithIdentifier:@"addCateChild" sender:nil];
                                                              }];
return @[edit];
}

当我在模拟器中运行它时,它工作正常。看截图:

This is what working on simulator.

当我在 iPhone 中运行它时,它会显示“删除”按钮而不是“编辑”按钮。看截图-

enter image description here

我无法理解代码中可能存在的问题。当我在“editActionsForRowAtIndexPath”中放置一个断点时,它不会被 iPhone 击中,但会被模拟器击中。

如果有人知道这个问题,请帮助我。

提前致谢。

最佳答案

对于从 5 到 8 的所有 iOS,使用 MGSwipeTableCell

Tested on all iOS versions on iPhone and iPad: iOS 5, iOS 6, iOS 7 and iOS 8.

虽然 MGSwipeTableCell 不是对仅在 iOS 8+ 中可用的 editActionsForRowAtIndexPath 的直接响应,但它是一个合理的替代方案。它还允许多个按钮和多个滑动方向。

关于ios - 方法不是在 iPhone 中调用而是在 iOS 模拟器中调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31376249/

相关文章:

iphone - 如何将字符串中的单个字符保存到 NSDictionary 对象中

ios - 不同的苹果证书

iphone - 如何将日期字符串从 twitter 设置为 NSDATE

ios - 使用 key 和消息快速创建哈希

iphone - 应用程序崩溃 iPhone 5 及以下

iphone - 替换对象索引 :withObject: not working when passing in a NSString object

ios - 使用IOS SDK 3.0发布到 friend 墙

objective-c - 获取 NSButton 上的悬停事件以显示图像

ios - 程序化设备特定 iOS 约束为零

ios - 你能将 UIImage exif 数据复制到缩放后的 UIImage 中吗?