0

我收到一个 SIGABRT 错误,我真的很生气,你能帮帮我吗?我知道该错误是由于应用程序委托中的某些内容造成的。我浏览了几次代码并检查了情节提要,但那里没有问题。甚至 Parse 也在正确编译。

#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
4

1 回答 1

-1

您的代码的以下行是错误的

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

因为self.window.rootViewController;只会返回UIViewController。不是UITabBarController

正确的代码是

 UITabBarController *tabBarController = self.window.rootViewController.tabBarController;
于 2013-02-22T01:47:46.230 回答