Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.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 iOS 5:UITableItem设置FinishedSelectedImage:具有FinishedSelectedImage:不工作/被忽略_Iphone_Ios_Ios5_Uitabbar_Uitabbaritem - Fatal编程技术网

Iphone iOS 5:UITableItem设置FinishedSelectedImage:具有FinishedSelectedImage:不工作/被忽略

Iphone iOS 5:UITableItem设置FinishedSelectedImage:具有FinishedSelectedImage:不工作/被忽略,iphone,ios,ios5,uitabbar,uitabbaritem,Iphone,Ios,Ios5,Uitabbar,Uitabbaritem,按照苹果的说法 我试图在UITabBarItem上设置自定义完成的选定和未选定图像,如下所示: ... DetailViewController *vc1 = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil]; UITabBarItem *vc1i = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemTopRated t

按照苹果的说法

我试图在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];
...
基本上,TabBar加载得很好,它完全忽略了TabBar项的自定义

我的目标是iOS5+

图像为30x30透明PNG,存在于项目中。我想不出我在这里忽略了什么,但一定是什么东西

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

有人有什么想法吗


谢谢

使用以下方法初始化选项卡栏项:
initWithTabBarSystemItem:tag:
。但是,正如文件所说:

此方法返回系统提供的选项卡栏项。稍后无法更改返回项目的标题和图像属性

您应该使用
initWithTitle:image:tag:
初始化选项卡栏项

UITabBarItem *vc1i = [[UITabBarItem alloc] initWithTitle:@"Top Rated" image:nil tag:100];
[vc1i setFinishedSelectedImage:[UIImage imageNamed:@"tab_bar_item_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_bar_item_normal.png"]];

选项卡栏项使用以下方法初始化:
initWithTabBarSystemItem:tag:
。但是,正如文件所说:

此方法返回系统提供的选项卡栏项。稍后无法更改返回项目的标题和图像属性

您应该使用
initWithTitle:image:tag:
初始化选项卡栏项

UITabBarItem *vc1i = [[UITabBarItem alloc] initWithTitle:@"Top Rated" image:nil tag:100];
[vc1i setFinishedSelectedImage:[UIImage imageNamed:@"tab_bar_item_selected.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tab_bar_item_normal.png"]];

如果您试图在UITabBar上显示实际图像,请使用以下代码

[yourTabBarItem setImage:[[UIImage imageNamed:@"more.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
如果您想为所选图像以原始状态显示图像,请使用以下命令

[yourTabBarItem setSelectedImage:[[UIImage imageNamed:@"more.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
这两个都是替代品

setFinishedSelectedImage:  withFinishedUnselectedImage:

如果您试图在UITabBar上显示实际图像,请使用以下代码

[yourTabBarItem setImage:[[UIImage imageNamed:@"more.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
如果您想为所选图像以原始状态显示图像,请使用以下命令

[yourTabBarItem setSelectedImage:[[UIImage imageNamed:@"more.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
这两个都是替代品

setFinishedSelectedImage:  withFinishedUnselectedImage:

哎呀,我知道我错过了一些简单的东西——非常感谢!这个方法已经被弃用了。哎呀,我知道我错过了一些简单的东西——非常感谢!此方法已弃用。注意:setFinishedSelectedImage:WithFinishedSelectedImage:需要iOS 5。注意:setFinishedSelectedImage:WithFinishedSelectedImage:需要iOS 5。