简体   繁体   English

ios应用崩溃

[英]ios app is crashing

I'm having a problem with my app crashing. 我的应用崩溃时遇到了问题。 The main root controller is a tab controller. 主根控制器是选项卡控制器。 inside the tab controller i have 4 buttons that have a nav controllers hooked up to them. 在选项卡控制器中,我有4个按钮,这些按钮具有连接到它们的导航控制器。 inside the nav controller, i have a table controller with a few cells. 在导航控制器内部,我有一个带有几个单元格的表控制器。 when you click a cell, it takes you to a view controller. 单击单元格时,它将带您到视图控制器。 now when i click on the cell and it takes me to the view controller. 现在,当我单击单元格时,它将带我到视图控制器。 when i click on the back arrow on the nav controller, it takes me back to the table view, which is great, but when i click on a new cell, the app crashes. 当我单击导航控制器上的后退箭头时,它带我回到表格视图,这很棒,但是当我单击一个新单元格时,应用程序崩溃。 everytime i click a cell, go back, and click another cell, the app crashes. 每当我单击一个单元格,返回并单击另一个单元格时,应用程序崩溃。 what am i doing wrong? 我究竟做错了什么? i think i too care of all my releases. 我想我也很在乎我的所有发行。 not sure though. 虽然不确定。

Theres an error I get when I run the program. 运行程序时出现错误。 It reads: 内容为:

Book Nav Controller (Medical How To's) has it 'NIB Name" property set to 'BookTableViewController.nib', but this view controller is not intended to have its view set in this manner. Book Nav控制器(“医疗方法”)将其“ NIB名称”属性设置为“ BookTableViewController.nib”,但是此视图控制器无意以这种方式设置其视图。

I'm also getting setText is deprecated on this code: 我也在此代码上弃用setText:

cell.text = [breakdownArray objectAtIndex:row];

What do I change it to? 我将其更改为什么?

Also My didSelectRowAtIndexPath code is: 我的didSelectRowAtIndexPath代码也是:

NSInteger row = [indexPath row];
if (self.bookDetailViewController == nil); {
    BookDetailViewController *aBookDetail = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:nil];
    self.bookDetailViewController = aBookDetail;

    [aBookDetail release];

}

bookDetailViewController.title = [NSString stringWithFormat:@"%Breakdown" , [breakdownArray objectAtIndex:row]];

Surviving2012AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.breakdownNavController pushViewController:bookDetailViewController animated:YES];

[delegate release];

}
cell.text = [breakdownArray objectAtIndex:row];

Should be: 应该:

cell.textLabel.text = [breakdownArray objectAtIndex:row];

bookDetailViewController.title = [NSString stringWithFormat:@"%Breakdown" , [breakdownArray objectAtIndex:row]];

Should be: 应该:

bookDetailViewController.title = [NSString stringWithFormat:@"%@", [breakdownArray objectAtIndex:row]];

If you're calling this from one of the viewControllers in the tabBarController, then this: 如果您是从tabBarController中的其中一个viewControllers调用此函数,则此代码为:

Surviving2012AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.breakdownNavController pushViewController:bookDetailViewController animated:YES];
[delegate release];

Should be: 应该:

[self.navigationController pushViewController:bookDetailViewController animated:YES];

And if it's still crashing after that, then you'll need to post how you're defining: 如果在那之后它仍然崩溃,那么您需要发布您的定义方式:

bookDetailViewController in your .h file, and the contents of your viewWillAppear and viewDidLoad methods. .h文件中的bookDetailViewController以及viewWillAppear和viewDidLoad方法的内容。

As for your deprecated method: 至于您不赞成使用的方法:

change it to : 更改为:

cell.textlabe.text = [breakdownArray objectAtIndex:row];

And I dont get the hang of this: 我不明白这一点:

 Surviving2012AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.breakdownNavController pushViewController:bookDetailViewController animated:YES];

[delegate release];

You said that you have a navigationController in every tab? 您说每个选项卡中都有一个NavigationController吗? Then why don't you use it? 那你为什么不使用它呢?

[self.navigationController pushViewController:bookDetailViewController


animated:YES];

Apple的iOS参考库(可在Xcode的“帮助”->“开发人员文档”下找到)非常清楚地列出了用.textLabel和.detailTextLabel替换不推荐使用的.text属性的方法

definitely don't call release on the delegate. 绝对不要在代理上调用release。 you only call release on an object when you have used a method on it which contains: alloc/init, copy, new or retain. 仅当在对象上使用包含以下内容的方法时,才对对象调用release:分配/初始化,复制,新建或保留。 otherwise you are likely releasing an autoreleased instance, which will cause it to crash. 否则,您可能会释放自动释放的实例,这将导致它崩溃。

fix this, if it still happens, post your results, and we will have another look. 请解决此问题,如果仍然发生,请发布您的结果,我们将再进行其他外观。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM