应用程序在ios 5.1中正常工作但在ios 6中崩溃

时间:2012-09-21 15:09:56

标签: ios xcode crash ios6 xcode4.5

我的应用在ios 5.1和xcode 4.4.1中运行良好 现在当我更新ro ios 6和xcode 4.5时,它会在更改视图时崩溃。 我使用故事板来制作我的UI。 在第一个视图中,我得到了TableViewController,当我选择一个单元格时,它应该转到另一个包含3个按钮,1个滑块,1个UITableView和2个标签的视图。那些东西用IBOutlet连接到控制器。 在第二个视图中,在结束此方法之后发生崩溃我认为

-(void)viewWillAppear:(BOOL)animated

以及此时的代码库存

0x347735aa:  ldr    r4, [r0]

我该怎么办? 编辑: 这是我的堆栈跟踪

0 objc_msgSend
1 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]:
2 -[UITableView _userSelectRowAtPendingSelectionIndexPath:]:
3 __NSFireDelayedPerform:
4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__:
5 __CFRunLoopDoTimer:
6 __CFRunLoopRun:
7 CFRunLoopRunSpecific:
8 CFRunLoopRunInMode:
9 GSEventRunModal:
10 UIApplicationMain:
11 main at main.m:14:

3 个答案:

答案 0 :(得分:2)

willSelectRowAtIndexPath方法语法错误。 它应该是

-(NSIndexPath *)tableView:willSelectRowAtIndexPath:不是

-(void)tableView:willSelectRowAtIndexPath:

答案 1 :(得分:1)

我在追踪后发现了问题并反复阅读我的代码。问题是我使用了这种方法

- (void)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath

知道哪个单元确实选择了。但我认为ios 6遇到了这种方法的问题。所以当我把它改成

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
一切顺利。 我仍然不知道为什么会这样。

答案 2 :(得分:0)

tableView:willSelectRowAtIndexPath:仅通知代表即将选择表中的行,如果您不希望选择特定行,则可以返回nil,或返回不同的行IndexPath,如果您认为您的应用需要它。

由于该方法从未打算触发深入到您的详细视图控制器,我认为您的旧调用在iOS 6上崩溃是公平的。您以前的工作“幸运”。