Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.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
Iphone 如何控制Abbar 我在内容的中间创建了UITABAR(项目:信息、位置和描述),现在我想为选项卡设置自定义背景图像,默认选择第一个按钮并在用户选择另一个选项卡项目时得到动作。_Iphone_Objective C_Xcode_Storyboard_Uitabbar - Fatal编程技术网

Iphone 如何控制Abbar 我在内容的中间创建了UITABAR(项目:信息、位置和描述),现在我想为选项卡设置自定义背景图像,默认选择第一个按钮并在用户选择另一个选项卡项目时得到动作。

Iphone 如何控制Abbar 我在内容的中间创建了UITABAR(项目:信息、位置和描述),现在我想为选项卡设置自定义背景图像,默认选择第一个按钮并在用户选择另一个选项卡项目时得到动作。,iphone,objective-c,xcode,storyboard,uitabbar,Iphone,Objective C,Xcode,Storyboard,Uitabbar,下面是选项卡栏的ss: 请告诉我这些问题的答案: 如何为此选项卡栏设置自定义背景图像 如何获取所选项目 如何默认选定的第一项 现在我已经创建了UITabBar并将其包含在这个ViewController中,接下来是什么 这是ViewController。h: @interface ViewController : UIViewController<UITabBarDelegate> { UITabBar *tabBar; } @property (strong, nonato

下面是选项卡栏的ss:

请告诉我这些问题的答案:

  • 如何为此选项卡栏设置自定义背景图像
  • 如何获取所选项目
  • 如何默认选定的第一项
  • 现在我已经创建了UITabBar并将其包含在这个ViewController中,接下来是什么

    这是ViewController。h:

    @interface ViewController : UIViewController<UITabBarDelegate> {
        UITabBar *tabBar;
    }
    @property (strong, nonatomic) IBOutlet UITabBar *tabBar;
    ...
    

    当用户在某个选项卡栏项目上单击选项卡时,我现在如何默认选择项目并获取?

    这是我用于以下目的的链接:


    我希望这对您有所帮助。

    link@iremk给您的第5步是定制选项卡栏所必须做的,即使它不受AppDelegate控制:只要您在viewController或其他任何地方有一个对它的引用,您就可以使用UITabBar类的方法/属性

    顺便说一句,如果“自定义”的意思是在项目上设置图标,并保持选项卡栏的灰色样式,则可以在InterfaceBuilder中设置项目的
    Image
    属性

    对于步骤2和3,只需查看UITabBar和UITabBarDelegate文档:


    tnx用于链接,但这是底部的选项卡栏,由AppDelegate控制。我在内容的中间有Tabar(图像示例)。你知道如何控制这个标签栏吗?我将UITabBar子类包括在ViewController中,并在viewDidLoad中称为“OfferTabBar*tab=[[OfferTabBar alloc]init];”。下一步是什么?tnxok,所以在tabbar样式中有3个按钮,您可以像这三个按钮一样操作。通过我上面提供的链接,您可以设置选中和未选中的图像。选择项目后,您可以将其存储在appdelegate或nsuserdefaults中。。我希望这能解决你的问题。请看一下我的答案,它仍然能回答你的帖子。请在你发布/更新问题时注意预览和格式化。tnx和sry,但请再帮我一件事。-(void)选项卡栏:(UITabBar*)选项卡栏didSelectItem:(UITabBarItem*)项{..不起作用。我需要将自定义UITabbar与或连接起来吗?事实上。调用此方法的方法之一是将重写此方法的类的实例分配给UITabbar的
    delegate
    属性。是的,我没有委托我的选项卡栏。现在正在工作。感谢您的帮助。:)
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation OfferViewController
    
    @synthesize tabBar;
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        UIImage *selectedImage0 = [UIImage imageNamed:@"HomeDB.png"];
        UIImage *unselectedImage0 = [UIImage imageNamed:@"HomeLB.png"];
    
        UIImage *selectedImage1 = [UIImage imageNamed:@"ScheduleDB.png"];
        UIImage *unselectedImage1 = [UIImage imageNamed:@"ScheduleLB.png"];
    
        UIImage *selectedImage2 = [UIImage imageNamed:@"BuildingsDB.png"];
        UIImage *unselectedImage2 = [UIImage imageNamed:@"BuildingsLB.png"];
    
    
        //UITabBar *tabBar = self.tabBar;
        UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
        UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
        UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
    
    
        [item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
        [item1 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
        [item2 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
    
        [super viewDidLoad];
    }
    ...