应用程序在模拟器8上崩溃但在设备上没有崩溃

时间:2015-01-08 20:42:50

标签: objective-c ios8 xcode6

我将Xcode更新为版本6,并将我的iOS应用程序的部署目标从之前的7.0更改为8.1。在此更新之前,应用程序在我的iPad和iOS模拟器上运行没有任何问题。然而,在更新之后,我可以像以前一样在我的设备上运行应用程序(以前的iOS 7,但也刚刚更新到iOS 8.1),但它在模拟器上崩溃并带有NSInvalidArgumentException:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell disclosureButton]: unrecognized selector sent to instance 0x7f85c7f0'    

对于这个问题,关于BuildingCell或disclosureButton并没有什么特别之处。但是当我尝试向公开按钮添加动作时,应用程序崩溃了。

BuildingCell标题:

@interface BuildingsCell : UITableViewCell

@property (strong, nonatomic) UIButton *disclosureButton;

@end

应用程序崩溃的功能:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"BuildingCell";
    BuildingsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [BuildingsCell.alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    cell.accessoryType = UITableViewCellAccessoryNone;

    //*** App crashes on the line below ***
    [cell.disclosureButton addTarget:self action:@selector(tappedCell:)forControlEvents:UIControlEventTouchUpInside];

    Building *currentBuilding = self.buildingArray[indexPath.row];

    return cell;
}

功能我尝试链接到disclosureButton

- (void) tappedCell:(id)sender
{
   CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.buildingTableView];
   NSIndexPath *indexPath = [self.buildingTableView indexPathForRowAtPoint:buttonPosition];

  [self tableView:self.buildingTableView accessoryButtonTappedForRowWithIndexPath:indexPath];
}

我发现代码没有任何问题。是否有可能是模拟器出现问题?模拟器是否有我需要设置的参数?我有一段时间没有做过Xcode或这个应用程序,我显然遗漏了一些东西。在这一点上,任何建议都会有所帮助,因为我不在乎。

1 个答案:

答案 0 :(得分:0)

哇。哇。 。 。所以我在申请中发现了这个问题。它远不及我的预期。

问题实际上是本地化问题之一。我的应用程序是法语,但我有一个不完整的英语故事板(早期的尝试,使应用程序双语),在很久以前就被搁置了。因此,尽管我将模拟器的语言设置为法语,但每次应用程序在模拟器上运行时,它都使用不完整的英语故事板。我没注意到,由于崩溃,只有初始视图(不包含语言区分信息)可见。

看起来Xcode 6已经进行了一些本地化更新。

我通过在编辑方案中将应用程序语言设置为“法语”来解决了这个问题。

所以,你好。 。现在感觉有点羞怯。

感谢您的建议。

相关问题