我收到一个SIGABRT错误,我真的很烦恼,请你帮助我。我知道错误是由于app委托中的某些内容造成的。我经历了几次代码并检查了故事板,但那里没有问题。甚至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
答案 0 :(得分:-1)
您的代码的以下行是错误的
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
因为 self.window.rootViewController;
只会返回 UIViewController 。不是 UITabBarController
正确的代码是
UITabBarController *tabBarController = self.window.rootViewController.tabBarController;