我得到了一個在我的AppDelegate中以編程方式創建的UITabBarController。我還創建了兩個帶有一些UIViewControllers的UINavigationController。我添加導航控制器到的UITabBarController,像這樣:推UIViewController到UINavigationController(也在UITabBarController中)
BVMapViewController *mapViewController = [[[BVMapViewController alloc] initWithNibName:@"BVMapViewController_iPhone" bundle:nil] autorelease];
BVFavoritesViewController *favoritesViewController = [[[BVFavoritesViewController alloc] initWithNibName:@"BVFavoritesViewController_iPhone" bundle:nil] autorelease];
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:mapViewController] autorelease];
[navigationController setToolbarHidden:YES];
UINavigationController *navigationControllerForFavorites = [[[UINavigationController alloc] initWithRootViewController:favoritesViewController] autorelease];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
NSArray* controllers = [NSArray arrayWithObjects:navigationController, navigationControllerForFavorites, nil];
self.tabBarController.viewControllers = controllers;
[self.window setRootViewController:self.tabBarController];
結果工作正常創建與兩個導航控制器標籤欄控制器。
問題如下: 第一個UINavigationController包含一個帶有MKMapView的UIViewController。該地圖顯示了一堆POI,因此當您點擊其中一個POI時,該應用向web服務(在後臺)發送一個請求,該請求一旦完成,它會通知視圖控制器將另一個UIViewController推入導航堆棧顯示關於POI一些更多的信息,
[self.navigationController pushViewController:self.stationViewController
animated:YES];
在這裏,我得到以下錯誤:
_WebTryThreadLock(bool), 0x11d9b560: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now... 1 0x58a76a9 WebThreadLock 2 0x5bfdfe -[UITextView _updateForNewSize:withOldSize:] 3 0x5c00b4 -[UITextView setFrame:] 4 0x4c59df UIViewCommonInitWithFrame 5 0x4c5bae -[UIView initWithCoder:] 6 0x4d9fb7 -[UIScrollView initWithCoder:] 7 0x5bc851 -[UITextView initWithCoder:] 8 0x7b1a02 UINibDecoderDecodeObjectForValue 9 0x7b10e5 -[UINibDecoder decodeObjectForKey:] 10 0x6a2648 -[UIRuntimeConnection initWithCoder:] 11 0x7b1a02 UINibDecoderDecodeObjectForValue 12 0x7b1418 UINibDecoderDecodeObjectForValue 13 0x7b10e5 -[UINibDecoder decodeObjectForKey:] 14 0x6a1aa3 -[UINib instantiateWithOwner:options:] 15 0x566e37 -[UIViewController _loadViewFromNibNamed:bundle:] 16 0x567418 -[UIViewController loadView] 17 0x567648 -[UIViewController loadViewIfRequired] 18 0x567882 -[UIViewController view] 19 0x567b2a -[UIViewController contentScrollView] 20 0x57eef5 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] 21 0x57efdb -[UINavigationController _layoutViewController:] 22 0x57f286 -[UINavigationController _updateScrollViewFromViewController:toViewController:] 23 0x57f381 -[UINavigationController _startTransition:fromViewController:toViewController:] 24 0x57feab -[UINavigationController startDeferredTransitionIfNeeded:] 25 0x5804a3 -[UINavigationController pushViewController:transition:forceImmediate:] 26 0x580098 -[UINavigationController pushViewController:animated:] 27 0x386f -[BVMapViewController parserDidFinishWithStation:] 28 0x785c -[BVParser parseStation:] 29 0xf8a0d5 -[NSThread main] 30 0xf8a034 NSThread_main 31 0x94e53ed9 _pthread_start
我試圖在主線程中執行這一點,但推控制器獲取其觀點,全黑的。
先謝謝您,祝您有美好的一天。
非常感謝。黑屏的問題出現了,因爲我沒有在Interface Builder中設置視圖的屬性。 –