使用UITabbaritem作为一个UIButton
-
19-09-2019 - |
题
有没有办法使用UITabbaritem作为一个UIButton的方法吗? 我试图让其项目不会改变视图的TabBar。只是希望他们做在同一个视图控制器简单的动作。
感谢。
解决方案
这也可能是可能的,通过创建UITabBarDelegate
和贯彻正确的方法,但这样做会侵犯苹果公司的 HIG ,使你的应用程序被拒绝。 UIToolbar
是使用你描述正确的类。从该文档:
一个标签栏给用户的能力 不同的模式或视图之间切换 在应用领域,用户应 能够从访问这些模式 无处不在的应用程序。 然而,标签栏绝不应 用作工具栏,其中包含 上中的元素起作用的按钮 电流模式(见“工具栏”更多 工具栏上的信息)。
其他提示
没有。它从UIBarItems继承:NSObject的。的UIButton从UIControl继承。
尝试此
UIButton *chatButton = [UIButton buttonWithType:UIButtonTypeCustom];
[chatButton setImage:[UIImage imageNamed:@"list.png"] forState:UIControlStateNormal];
[chatButton addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
chatButton.frame = (CGRect) {
.size.width = 30,
.size.height = 35,
};
UIBarButtonItem *barBackButton= [[UIBarButtonItem alloc] initWithCustomView:chatButton];
[navigationItem setLeftBarButtonItem:barBackButton];
NSArray *barItemArray = [[NSArray alloc]initWithObjects:navigationItem,nil];
[navigationBar setItems:barItemArray];
不隶属于 StackOverflow