2010-06-28 30 views

回答

5

您可以禁用和啓用所有的UI與

[[UIApplication sharedApplication] beginIgnoringInteractionEvents]; 

[[UIApplication sharedApplication] endIgnoringInteractionEvents]; 

話雖這麼說,我建議挖下來理解爲什麼應用程序崩潰,因爲你將要解決的問題,而不是隱瞞錯誤。

一個快速拍攝:你是否正在另一個線程上加載?您只能從主線程更新UI。

9

這裏是啓用/禁用標籤欄中所有項目的代碼。

+(void) setAllItemsInTabBar:(UITabBarController *)aTabBar toEnableState:(BOOL)enableState 
{ 
    NSArray *tabItems = aTabBar.tabBar.items; 
    for (UIBarItem *tabItem in tabItems) 
    { 
     [tabItem setEnabled:enableState]; 
    } 
} 
+0

它幫助我。謝謝! – mxg 2013-03-28 06:31:33

6

解決此問題的另一種方法將符合<UITabBarControllerDelegate>協議。

@interface SomeViewController : UIViewController <UITabBarControllerDelegate> 
@property (nonatomic) BOOL tabbarShouldRespond; 
//.. 
//.. 

然後

@implementation SomeViewController 
//.. 
// become the delegate for our UITabBarController - probably in viewDidLoad 
self.tabBarController.delegate = self; 
//.. 
// set our BOOL for whether the tab bar should respond to touches based on program logic 
self.tabbarShouldRespond = NO; 
//.. 
//.. 
#pragma mark <UITabBarControllerDelegate> 
//Asks the delegate whether the specified view controller should be made active. 
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { 
    if (self.tabbarShouldRespond) { 
     return YES; 
    } else { 
     return NO; 
    } 
} 

蘋果文檔 - UITabBarControllerDelegate Protocol Reference

相關問題