2013-02-22 106 views
0

我得到一個SIGABRT錯誤,我真的很煩,請你幫助我。我知道錯誤是由應用程序委託中的某些內容引起的。我仔細檢查了代碼,並檢查了故事板,但這裏沒有問題。即使解析正在編譯。運行Appdelegate.m的應用程序錯誤(sigabrt錯誤)

#import "AppDelegate.h" 
#import <Parse/Parse.h> 

@implementation AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
// Parse Initialization 

..... 


//Custom Stuff Initialization 

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationBar"] forBarMetrics:UIBarMetricsDefault]; 

// Assign tab bar item with titles 
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; 
UITabBar *tabBar = tabBarController.tabBar; 
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0]; 
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1]; 
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2]; 
UITabBarItem *tabBarItem4 = [tabBar.items objectAtIndex:3]; 

tabBarItem1.title = @"Dashboard"; 
tabBarItem1.titlePositionAdjustment = UIOffsetMake(0.0, -5.5); 
tabBarItem2.title = @"Interactions"; 
tabBarItem2.titlePositionAdjustment = UIOffsetMake(0.0, -5.5); 
tabBarItem3.title = @"Messages"; 
tabBarItem3.titlePositionAdjustment = UIOffsetMake(0.0, -5.5); 
tabBarItem4.title = @"Me"; 
tabBarItem4.titlePositionAdjustment = UIOffsetMake(0.0, -5.5); 

[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"pen_sIMG.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"pen_usIMG.png"]]; 
[tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"comment_sIMG.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"comment_usIMG.png"]]; 
[tabBarItem3 setFinishedSelectedImage:[UIImage imageNamed:@"message_sIMG.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"message_usIMG.png"]]; 
[tabBarItem4 setFinishedSelectedImage:[UIImage imageNamed:@"star_sIMG.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"star_usIMG.png"]]; 


// Change the tab bar background 
UIImage* tabBarBackground = [UIImage imageNamed:@"tabBarBg-icns.png"]; 
[[UITabBar appearance] setBackgroundImage:tabBarBackground]; 
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabBarBg-selc.png"]]; 

// Change the title color of tab bar items 
UIColor *titleNormColor = [UIColor colorWithRed:137/255.0 green:137/255.0 blue:137/255.0 alpha:1.0]; 
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
                titleNormColor, UITextAttributeTextColor, 
                nil] forState:UIControlStateNormal]; 


UIColor *titleHighlightedColor = [UIColor colorWithRed:73/255.0 green:130/255.0 blue:202/255.0 alpha:1.0]; 
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
                titleHighlightedColor, UITextAttributeTextColor, 
                nil] forState:UIControlStateHighlighted]; 


return YES; 
} 



@end 
+0

沒有人可以幫你。您需要發佈完整的錯誤。在調試器中運行時會發生崩潰嗎?哪一行代碼導致了這個問題? – rmaddy 2013-02-22 02:32:00

+0

注意:您應該不會發布您的Parse應用程序ID和客戶端密鑰。我建議你從你的問題中刪除這些。 – rmaddy 2013-02-22 02:33:34

+0

您是否在您的調試方案中啓用了殭屍併爲Objective-C異常添加了斷點?這應該給你更多的信息,瞭解錯誤發生的地點和原因。 – TheEye 2013-02-22 15:34:30

回答

-1

下面的一行代碼是錯誤的

UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; 

因爲self.window.rootViewController;只會返回的UIViewController。不是的UITabBarController

正確的代碼

UITabBarController *tabBarController = self.window.rootViewController.tabBarController; 
+0

如果根視圖控制器實際上是一個'UITabBarController',那麼原始代碼行就可以了。 – rmaddy 2013-02-22 02:31:19

+0

哦,我看到...... – 2013-02-22 08:58:45