标签: uitabbaritem

自定义UITabBarItem的图标位置和标题(iphone sdk)

我有一个tabBar,我想自定义标签栏中的项目.我想阻止标题的显示(通过将标题设置为nil很容易实现),并将图标位置重置为中心垂直位置.有没有人知道如何做到这一点?

谢谢.

iphone cocoa-touch uitabbaritem uitabbar

1
推荐指数
1
解决办法
4186
查看次数

如何在Tab栏中添加"更多"按钮?

我的iPhone应用程序在视图底部有一个标签栏控制器 - 此刻我有三个按钮.但是,我想添加更多,但为了这样做,我需要将三个按钮中的最后一个按钮变为"更多..."按钮,因为否则其他按钮上的文本会相互碰撞.

我知道如果标签栏中有超过5个按钮,那么它会自动创建一个更多的按钮 - 但是有没有办法通过编辑功能手动调用它?

谢谢.

iphone objective-c uitabbarcontroller uitabbaritem uitabbar

1
推荐指数
2
解决办法
1万
查看次数

在不更改视图控制器标题的情况下更改UITabBarItem的标题

我希望拥有它,以便视图控制器的标题与标签栏项目的标题不同.

我在viewDidLoad中尝试了以下内容

[self setTitle:@"My title"];
[[self tabBarItem] setTitle:@"Search"];
Run Code Online (Sandbox Code Playgroud)

但是对第二个函数的调用似乎不起作用

iphone objective-c uitabbaritem

1
推荐指数
1
解决办法
681
查看次数

iOS 5:UITabBarItem setFinishedSelectedImage:withFinishedUnselectedImage:not working/ignored

根据Apple 文档

我正在尝试在UITabBarItem上设置自定义完成的已选择和未选择的图像,如下所示:


...
DetailViewController *vc1 = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
UITabBarItem *vc1i = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemTopRated tag:100];
[vc1i setFinishedSelectedImage:[UIImage imageNamed:@"tab_bar_item_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_bar_item_normal.png"]];
[vc1 setTabBarItem:vc1i];
...
Run Code Online (Sandbox Code Playgroud)

基本上正在发生的事情是TabBar加载得很好,它只是完全忽略了标签栏项目的自定义.

我的目标是iOS5 +

图像是30x30透明PNG并存在于项目中.无法弄清楚我在这里俯瞰什么,但一定是什么东西!

这是在tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath方法中调用的,ala Ray Wenderlich的教程

有人有主意吗?

谢谢!

iphone uitabbaritem uitabbar ios ios5

1
推荐指数
1
解决办法
6550
查看次数

tabbar项目图像和selectedImage

我有一个标签栏控制器(它是一个基于标签栏的应用程序,因此标签栏位于MainWindow.xib上).在这个xib中,我添加了4个标签栏项目,并设置了所有标签栏项目的图像.因此,我面临两个问题:

1)图像是白色的,但是当我运行应用程序时,它显示标签栏项目上的所有图像为灰色.如何使其看起来与原始图像中的相同.

2)我有一个选定的图像,我想在当前选中的标签栏项目上添加.我该怎么办?

尼克代码后更新:

嘿,在iOS 5中,你必须在你的app委托中编写以下代码,用于设置选中和未选中的标签栏项目(类别解决方案仅适用于4):

if ([[[UIDevice currentDevice] systemVersion] floatValue]>4.9) {
    NSString *selectedImageName,*unselectedImageName;

    for (int counter = 0; counter < [self.tabBarController.tabBar.items count]; counter++) {
        if (counter==0) {
            selectedImageName = <someImagename>;
            unselectedImageName = <someImagename>;
        }
        else if (counter==1) {
            selectedImageName = <someImagename>;
            unselectedImageName = <someImagename>;
        }
        .
                    .
        else {
            selectedImageName = <someImagename>;
            unselectedImageName = <someImagename>;
        }
        UIImage *selectedImage = [UIImage imageNamed:selectedImageName];
        UIImage *unselectedImage = [UIImage imageNamed:unselectedImageName];

        UITabBarItem *item = [self.tabBarController.tabBar.items objectAtIndex:counter];
        if ([item respondsToSelector:@selector(setFinishedSelectedImage:withFinishedUnselectedImage:)]) {
            [item setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:unselectedImage];
        } …
Run Code Online (Sandbox Code Playgroud)

iphone uitabbarcontroller uitabbaritem ios

1
推荐指数
1
解决办法
1万
查看次数

TabBarImage未正确调整大小

我正在尝试将60x60像素分配给tabBarItem.image:

self.tabBarItem.image = [UIImage imageNamed:@"tab_settings@2x.png"];
Run Code Online (Sandbox Code Playgroud)

我在HIG上读到,我应该为Retina显示器放置60x60像素图像.但我得到的是尺寸不正确的图像:

在此输入图像描述

如果我把它设为30x30px,它看起来也很糟糕(不像Retina).

iphone objective-c uitabbaritem ipad ios

1
推荐指数
1
解决办法
1041
查看次数

在iPhone中推送UIViewController时如何更改tabbar项的选定索引

我正在将一个视图控制器推送到另一个视图控制器但是当我按下tabbar项时索引没有改变.如何在将视图从一个推送到另一个时更改所选索引.提前感谢.

iphone objective-c uitabbarcontroller uitabbaritem

1
推荐指数
2
解决办法
9128
查看次数

如何自定义iOS徽章编号背景

如何在UITabBarItem上自定义徽章编号?

像这样的东西

在此输入图像描述

iphone uitabbarcontroller uitabbaritem badge ios

1
推荐指数
1
解决办法
1589
查看次数

UICabBarItem外观为UIControlStateHighlighted

我在我的AppDelegate.m文件中有这个代码,didFinishLaunchingWithOptions:以便我可以有一个自定义字体.

[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                        [UIColor grayColor], UITextAttributeTextColor,
                                                        [UIFont fontWithName:@"Gotham-Medium" size:10], UITextAttributeFont, nil] forState:UIControlStateNormal];

[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                        [UIColor whiteColor], UITextAttributeTextColor,
                                                        [UIFont fontWithName:@"Gotham-Medium" size:10], UITextAttributeFont, nil] forState:UIControlStateHighlighted];
Run Code Online (Sandbox Code Playgroud)

字体更改按预期工作,但我在调试控制台中获得此输出:

button text attributes only respected for UIControlStateNormal, UIControlStateHighlighted and UIControlStateDisabled. state = 1 is interpreted as UIControlStateHighlighted.

uitabbaritem ios

1
推荐指数
1
解决办法
1422
查看次数

如何以编程方式点击Tabbar项目(not selectedIndex)

这是我的应用程序的简历:

  • 我有标签栏.当用户点击标签栏项目时
  • 适当的视图控制器由"滑动到侧面"动画呈现(如在iP主屏幕中).

代码在方法中tabBarController(tabBarController: UITabBarController, shouldSelectViewController viewController: UIViewController) -> Bool.

  • 我有警觉 当用户点击按钮时,我想将他指向特定的标签.但是当我使用时self.selectedIndex = #,VC会显示,但没有动画.有没有办法实现相同的动作,如点击项目?谢谢

uitabbarcontroller uitabbaritem ios swift uialertcontroller

1
推荐指数
1
解决办法
1371
查看次数