UITabBar无法更改所选索引 [英] UITabBar can't change selected index
本文介绍了UITabBar无法更改所选索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法更改我的UITabBar的索引。我试图从UITabBarController子类更改它。这是我正在尝试的:
I'm having trouble changing the index of my UITabBar. I am attempting to change it from the UITabBarController subclass. This is what I'm trying:
[self.tabBarController setSelectedIndex:1];
这是我的.h看起来像
#import <UIKit/UIKit.h>
@interface CustomTab : UITabBarController <UITabBarControllerDelegate>{
IBOutlet CustomTab *bar;
}
@end
我正在设置索引与IBAction,该方法正在被调用,但索引不会改变。任何想法?
I am trying to set the index with an IBAction, the method is being called, but the index doesn't change. Any ideas?
推荐答案
因为您正在致电
[self.tabBarController setSelectedIndex:1];
从CustomTab类本身。您需要将其替换为
from inside the CustomTab class itself. You need to replace it with
[self setSelectedIndex:1];
这篇关于UITabBar无法更改所选索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文