0

你能帮助理解那个崩溃日志吗?我不确定出了什么问题。

"0   MyApp                               0x0007af6f MyApp + 499567",
"1   MyApp                               0x0007b6d1 MyAPp + 501457",
"2   libsystem_c.dylib                   0x33bb97e3 _sigtramp + 38",
"3   JavaScriptCore                      0x35668fef WTFReportBacktrace + 146",
"4   WebCore                             0x32b5740f WebThreadLock + 54",
"5   UIKit                               0x310ec4bf -[UIFieldEditor scrollXOffset] + 10",
"6   UIKit                               0x310ec463 -[UITextField _endedEditing] + 166",
"7   UIKit                               0x310ec375 -[UITextField willDetachFieldEditor:] + 44",
"8   UIKit                               0x310b616d -[UIFieldEditor becomeFieldEditorForView:] + 168",
"9   UIKit                               0x310ec0bd -[UITextField _resignFirstResponder] + 188",
"10  UIKit                               0x30fd1695 -[UIResponder resignFirstResponder] + 128",
"11  UIKit                               0x30ff6c7b -[UITextField resignFirstResponder] + 150",
"12  UIKit                               0x310b000f -[UIView(Hierarchy) _removeFirstResponderFromSubtree] + 146",
"13  UIKit                               0x3118fe4b __UIViewWillBeRemovedFromSuperview + 54",
"14  UIKit                               0x30fd0cbd -[UIView(Hierarchy) removeFromSuperview] + 56",
"15  UIKit                               0x31069873 -[UITransitionView _didCompleteTransition:] + 422",
"16  UIKit                               0x310691a3 -[UITransitionView transition:fromView:toView:] + 1402",
"17  UIKit                               0x31068c21 -[UITransitionView transition:toView:] + 104",
"18  UIKit                               0x310687ed -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 524",
"19  UIKit                               0x310685db -[UITabBarController transitionFromViewController:toViewController:] + 30",
"20  UIKit                               0x31067f15 -[UITabBarController _setSelectedViewController:] + 300",
"21  UIKit                               0x31067c49 -[UITabBarController setSelectedIndex:] + 240",
"22  MyApp                               0x00002f6d MyApp + 8045",
"23  MyApp                               0x000789ef MyApp + 489967",
"24  MyApp                               0x0007644f MyApp + 480335",
"25  Foundation                          0x37ae1a81 -[NSThread main] + 72",
"26  Foundation                          0x37b75591 __NSThread__main__ + 1048",
"27  libsystem_c.dylib                   0x33b70735 _pthread_start + 320",
"28  libsystem_c.dylib                   0x33b705f0 thread_start + 8"

第 22 行:这是那个函数:

- (UIViewController *) selectTabBarItemWithTag:(NSInteger) tag
{
    NSArray *viewControllers = self.rootController.viewControllers;

    int idx = 0;
    for (UIViewController *vc in viewControllers) {
        if (vc.tabBarItem.tag == tag) {
            self.rootController.selectedIndex = idx;
            return vc;
        }

        idx++;
    }

    return nil;
}
4

2 回答 2

0

检查页面上存在的 UITextField 对象。因为resignFirstResponder在您的 UIViewController 上处于活动状态的 UITextField 方法上出现错误。也许最好resignFirstResponder在 UIViewController 的方法调用viewWillDisappear:中添加方法,这将被更改。实际上你的问题很接近下一个: UITextFieldDelegate 问题

于 2012-09-19T07:44:09.060 回答
0

您是否尝试过从快速枚举结构中删除您的代码?

for (int i = 0; i < [viewControllers count]; i++) {
    UIViewController *vc = [viewControllers objectAtIndex:i];
    if (vc.tabBarItem.tag == tag) {
        self.rootController.selectedIndex = i;
        return vc;
    }
}
于 2015-04-30T13:14:50.227 回答