【问题标题】:App crashes on device but not in simulator pushing an UITableView应用程序在设备上崩溃,但在模拟器中没有推送 UITableView
【发布时间】:2012-10-19 22:28:14
【问题描述】:

这是我第一次在这里写但是我有一个无法处理的问题:(...

当我在另一个表中推送一个单元格后推送一个 UITableView 时出现问题,如果我创建一个通用 UITableViewController 并推送它,它可以工作,但如果我用所有必要的方法重新定义类就不起作用了。

我之前在其他代码中实现了这个并且它可以工作,但是现在,在更新到 Xcode 4.5 之后,它就不能工作了......

这是我要推送的视图源代码:

@interface ECDetailSettingsTableView ()

@end

@implementation ECDetailSettingsTableView

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return 4;
}

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

    if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ECDetailSettingsCell"];

    // Configure the cell...

    return cell;
}

这是推送 tableview 的代码:

/********************* Pushing View *********************/
[tableView deselectRowAtIndexPath:indexPath animated: YES];

_themeTable = [self.storyboard instantiateViewControllerWithIdentifier:@"ECDetailSettingsViewController"];
[self.navigationController pushViewController:_themeTable animated:YES];

PD:谢谢大家,如果我犯了语法错误,我们深表歉意:)。

【问题讨论】:

  • 错误是什么?堆栈跟踪有什么帮助吗?如果没有更多细节,就无法提供帮助。
  • 问题是在模拟器中运行良好,但是当我在 iPod 上运行时,应用程序崩溃并且我看不到堆栈跟踪,因为 Xcode 无法处理该过程:(。
  • 您的 iPad 是否安装了 iOS6?您在上面有 iOS6 特定代码。它会在 iOS5 设备上崩溃。这一行: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  • 但这与我在其他区域实现的代码相同:S。我在 iPod 上安装了 iOS5。如果删除该行,错误仍然出现...

标签: iphone ios xcode uitableview push


【解决方案1】:

如果您在故事板中使用 segue,可能会出现错误,因为这只适用于 iOS 6。

【讨论】:

  • 我没有使用 segue,我像其他时候一样手动推送它,但现在不起作用:(。
  • 很好地使用 Segues 是我的问题,我为 IOS 5.1 部署。我使用 XCode 4.4 和 IOS 6 模拟器。因此,使用 segues 应用程序可以在 IOS6 上运行,但不能在 IOS5 上运行。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-16
相关资源
最近更新 更多