我有一个有三个视图的UITabBarController。当我选择View#2时,应用程序崩溃(请参阅崩溃日志)。如果我重新排序选项卡,以便View#2首先运行(无崩溃)。
0 libobjc.A.dylib 0x3368ef78 objc_msgSend + 16
1 CoreFoundation 0x359b8e90 CFRetain + 76
2 CoreFoundation 0x359c2b74 +[__NSArrayI __new::] + 48
3 CoreFoundation 0x359c2a8e -[__NSPlaceholderArray initWithObjects:count:] + 294
4 CoreFoundation 0x359c27ce +[NSArray arrayWithObjects:count:] + 38
5 CoreFoundation 0x359c24f2 -[NSDictionary allValues] + 230
6 UIKit 0x333e7f46 -[UINib instantiateWithOwner:options:] + 538
7 UIKit 0x333563c0 -[UIViewController _loadViewFromNibNamed:bundle:] + 240
8 UIKit 0x33233c52 -[UIViewController loadView] + 82
9 UIKit 0x331a9c10 -[UIViewController view] + 44
10 UIKit 0x33209636 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 86
11 UIKit 0x332095d4 -[UITabBarController transitionFromViewController:toViewController:] + 24
12 UIKit 0x33208f0e -[UITabBarController _setSelectedViewController:] + 294
13 UIKit 0x3329244e -[UITabBarController _tabBarItemClicked:] + 338
14 CoreFoundation 0x359ca3f6 -[NSObject performSelector:withObject:withObject:] + 46
15 UIKit 0x3318be00 -[UIApplication sendAction:to:from:forEvent:] + 56
16 UIKit 0x3318bdbc -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 24
17 UIKit 0x332922d2 -[UITabBar _sendAction:withEvent:] + 346
18 CoreFoundation 0x359ca3f6 -[NSObject performSelector:withObject:withObject:] + 46
19 UIKit 0x3318be00 -[UIApplication sendAction:to:from:forEvent:] + 56
20 UIKit 0x3318bdbc -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 24
21 UIKit 0x3318bd9a -[UIControl sendAction:to:forEvent:] + 38
22 UIKit 0x3318bb0a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 486
23 UIKit 0x33292062 -[UITabBar(Static) _buttonUp:] + 110
24 CoreFoundation 0x359ca3f6 -[NSObject performSelector:withObject:withObject:] + 46
25 UIKit 0x3318be00 -[UIApplication sendAction:to:from:forEvent:] + 56
26 UIKit 0x3318bdbc -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 24
27 UIKit 0x3318bd9a -[UIControl sendAction:to:forEvent:] + 38
28 UIKit 0x3318bb0a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 486
29 UIKit 0x3318c442 -[UIControl touchesEnded:withEvent:] + 470
30 UIKit 0x3318a924 -[UIWindow _sendTouchesForEvent:] + 312
31 UIKit 0x3318a312 -[UIWindow sendEvent:] + 374
32 UIKit 0x3317068e -[UIApplication sendEvent:] + 350
33 UIKit 0x3316ff34 _UIApplicationHandleEvent + 5820
34 GraphicsServices 0x33762224 PurpleEventCallback + 876
35 CoreFoundation 0x35a4451c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
36 CoreFoundation 0x35a444be __CFRunLoopDoSource1 + 134
37 CoreFoundation 0x35a4330c __CFRunLoopRun + 1364
38 CoreFoundation 0x359c649e CFRunLoopRunSpecific + 294
39 CoreFoundation 0x359c6366 CFRunLoopRunInMode + 98
40 GraphicsServices 0x33761432 GSEventRunModal + 130
41 UIKit 0x3319ecce UIApplicationMain + 1074
42 TecNotes 0x000c2a28 main (main.m:18)
43 TecNotes 0x000c2940 start + 32
没有自定义类或实例初始化。并且View#2的viewDidLoad方法似乎没有执行。
为了调试问题,View#2的viewDidLoad已减少到以下内容。
- (void)viewDidLoad
{
NSLog(@"Enter View#2 viewDidLoad");
[super viewDidLoad];
NSLog(@"Exit View#2 viewDidLoad");
}
视图#1具有类似的记录,以记录调用viewDidLoad方法。
- (void)viewDidLoad
{
NSLog(@"Enter View#1 viewDidLoad");
[super viewDidLoad];
NSFileManager *filemgr = [NSFileManager defaultManager];
NSString *cd = [filemgr currentDirectoryPath];
recipeName = [cd lastPathComponent];
NSString *basedir = [CategoryViewController getBaseDir];
int startPos = [basedir length]+1;
int len = [cd length]-startPos;
NSString *tmp = [cd substringWithRange:NSMakeRange(startPos, len)];
title = [CategoryViewController decode:tmp];
//self.navigationItem.backBarButtonItem.title = recipeName;
//self.tabBarController.navigationItem.title = recipeName;
currentNote = 0;
//-------
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedScreen:)];
swipeGesture.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeGesture];
swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedScreen:)];
swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft ;
[self.view addGestureRecognizer:swipeGesture];
//-------
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed)];
self.navigationItem.backBarButtonItem = back;
self.tabBarController.navigationItem.backBarButtonItem = back;
[noteView setFont:[UIFont systemFontOfSize:[NotesViewController getFontSize]]];
[self loadNotes];
NSLog(@"Exit View#1 viewDidLoad");
}
以下是生成的日志条目。
Dec 16 11:42:21 Tonys-iPad TecNotes [6577]:进入View#1 viewDidLoad
Dec 16 11:42:21 Tonys-iPad TecNotes [6577]:退出查看#1 viewDidLoad
Dec 16 11:42:27 Tonys-iPad ReportCrash [6580]:为流程TecNotes制定崩溃报告[6577]
12月16日11点42分27秒东尼斯-IPAD com.apple.launchd [1](UIKitApplication:com.bringardner.tecnotes [0x2bd8] [6577]):(UIKitApplication:com.bringardner.tecnotes [0x2bd8])工作似乎崩溃了:分段错误:11