iPhone App Crash使用UITabBarController

时间:2012-09-19 07:23:11

标签: iphone ios crash uitabbarcontroller

你能帮忙理解崩溃日志吗?我不确定有什么问题。

"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;
}

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分: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;
    }
}