我无法更改我的UITabBar的索引。我试图从UITabBarController子类中更改它。这就是我想:UITabBar无法更改所选索引
[self.tabBarController setSelectedIndex:1];
这是我的.h是什么样子
#import <UIKit/UIKit.h>
@interface CustomTab : UITabBarController <UITabBarControllerDelegate>{
IBOutlet CustomTab *bar;
}
@end
我想设置与IBAction为索引,该方法被调用,但指数不会改变。有任何想法吗?
这个工作从其他viewcontrollers,它有来自自身的UITabBarController被称为办? – davis
IBAction是否在CustomTab中实现?因为如果没有,你需要确保self.tabBarController指向你的CustomTab。 –
它是在CustomTab中实现的,我设置了一个按钮并添加如下所示的动作:'[button addTarget:nil action:@selector(change)forControlEvents:UIControlEventTouchUpInside];' – davis