Could you help to understand that crash log? I am not sure what is wrong.
"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"
Line 22: this is that function:
- (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;
}
Check UITextField objects which are present on your page. Because error appears on method of resignFirstResponder
for UITextField which is active on your UIViewController. Maybe it's better to add method resignFirstResponder
inside method call viewWillDisappear:
of UIViewController, which will be changed. Actually your problem is quite close to next: UITextFieldDelegate problem
Have you tried removing your code from a fast enumeration structure?
for (int i = 0; i < [viewControllers count]; i++) {
UIViewController *vc = [viewControllers objectAtIndex:i];
if (vc.tabBarItem.tag == tag) {
self.rootController.selectedIndex = i;
return vc;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.