Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITabBar-Wierd高差_Ios_Objective C_Xcode_Ios8_Uitabbarcontroller - Fatal编程技术网

Ios UITabBar-Wierd高差

Ios UITabBar-Wierd高差,ios,objective-c,xcode,ios8,uitabbarcontroller,Ios,Objective C,Xcode,Ios8,Uitabbarcontroller,我希望以编程方式添加条形图时显示在情节提要图像中的默认高度。知道怎么弄吗?下面是我用来向我的应用程序添加UITabBarController的代码 - (void)setCustomTabBar { //TODO: Fix TabBar height UITabBarController *tabBarController = [[UITabBarController alloc] init]; TimelineVC *tvc = [[TimelineVC alloc]

我希望以编程方式添加条形图时显示在情节提要图像中的默认高度。知道怎么弄吗?下面是我用来向我的应用程序添加
UITabBarController
的代码

- (void)setCustomTabBar
{
    //TODO: Fix TabBar height
    UITabBarController *tabBarController = [[UITabBarController alloc] init];

    TimelineVC *tvc = [[TimelineVC alloc] initWithNibName:@"TimelineVC" bundle:nil];
    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:tvc];

    TimelineVC *tvc2 = [[TimelineVC alloc] initWithNibName:@"TimelineVC" bundle:nil];
    UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:tvc2];
    tvc2.showFriends = true;

    NotificationVC *nvc = [[NotificationVC alloc] initWithNibName:@"NotificationVC" bundle:nil];
    nav3 = [[UINavigationController alloc] initWithRootViewController:nvc];

    ProfileVC *pvc = [[ProfileVC alloc] initWithNibName:@"ProfileVC" bundle:nil];
    UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:pvc];

    [[UITabBar appearance] setTintColor:[UIColor whiteColor]];
    [[UITabBar appearance] setShadowImage:nil];
    [tabBarController setViewControllers:@[nav1, nav2, nav3, nav4]];
    tabBarController.selectedIndex = 0;


    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat tabBarWidth = screenRect.size.width/4;

    [[UITabBar appearance] setBackgroundImage:[AppDelegate imageFromColor:[UIColor darkGrayColor] forSize:CGSizeMake(screenRect.size.width, 49) withCornerRadius:0]];
    [[UITabBar appearance] setSelectionIndicatorImage:[AppDelegate imageFromColor:[UIColor colorWithRed:26/255.0 green:163/255.0 blue:133/255.0 alpha:1] forSize:CGSizeMake(tabBarWidth, 49) withCornerRadius:0]];

    tabBarController.tabBar.translucent = NO;

    UIImage *normalImage, *selectedImages;
    normalImage =[UIImage imageNamed:@"TimeLineIcon"];
    selectedImages = [UIImage imageNamed:@"TimeLineIcon"];

    UIImage *normalImage2, *selectedImages2;
    normalImage2 =[UIImage imageNamed:@"FriendsIcon"];
    selectedImages2 = [UIImage imageNamed:@"FriendsIcon"];

    UIImage *normalImage3, *selectedImages3;
    normalImage3 =[UIImage imageNamed:@"NotificationIcon"];
    selectedImages3 = [UIImage imageNamed:@"NotificationIcon"];

    UIImage *normalImage4, *selectedImages4;
    normalImage4 =[UIImage imageNamed:@"ProfileIcon"];
    selectedImages4 = [UIImage imageNamed:@"ProfileIcon"];


    //TODO: FOR LOOP
    nav1.tabBarItem.selectedImage = [normalImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav1.tabBarItem.image = [selectedImages imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav1.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

    nav2.tabBarItem.selectedImage = [normalImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav2.tabBarItem.image = [selectedImages2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav2.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

    nav3.tabBarItem.selectedImage = [normalImage3 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav3.tabBarItem.image = [selectedImages3 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        nav3.tabBarItem.badgeValue = @"1";
    nav3.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

    nav4.tabBarItem.selectedImage = [normalImage4 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav4.tabBarItem.image = [selectedImages4 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav4.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);

    self.window.rootViewController = tabBarController;
    [self.window addSubview:tabBarController.view];

    [self enableSupportKit];
}
这对我有帮助。
希望有帮助。

检查您的launchImage。例如,它在您的模拟器中是正确的,但如果您使用iphone(我猜是iphone 6)。删除iphone6 launchimage,然后您会发现问题。

您可以添加用于添加工具栏的代码吗?将代码添加到原始帖子中。
[self.tabBar setFrame:CGRectMake(self.tabBar.frame.origin.x, self.tabBar.frame.origin.y, self.tabBar.frame.size.width, self.tabBar.frame.size.height)];