是否有可能在 iPad 的 UITabBar 中添加按钮?

Posted

技术标签:

【中文标题】是否有可能在 iPad 的 UITabBar 中添加按钮?【英文标题】:Is there a possibility to add button in UITabBar in IPad? 【发布时间】:2011-01-12 09:02:02 【问题描述】:

我想知道是否可以在 iPad 上的UITabBar 中添加UIButton。如果有,请告诉我。

【问题讨论】:

你看过uibarbuttonitem developer.apple.com/library/ios/ipad/#documentation/uikit/… 【参考方案1】:

如果您查看 @Kyle the Unruly 建议的文档,这相当简单。

这是一个添加内置按钮和您自己的图像的示例:

UIBarButtonItem * viewSnapShotButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(snapShotButtonPressed:)];
UIBarButtonItem * fontButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Font.png"] style:UIBarButtonItemStylePlain target:self action: @selector(fontSize:)];

// Add buttons to the tab bar
NSMutableArray *topCentreItems = [[NSMutableArray alloc] init];
UITabBar *topCentreTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 0, 120, 75];
[topCentreItems addObject:viewSnapShotButton];
[topCentreItems addObject:fontButton];
topCentreTabBar.items = topCentreItems;

【讨论】:

以上是关于是否有可能在 iPad 的 UITabBar 中添加按钮?的主要内容,如果未能解决你的问题,请参考以下文章

OC和Swift中的UITabBar和UINaviGationBar的适配 [UITabbar在IPad中的适配]

UITabBar 图标在 iPad 上偏离中心

iPad中的UITabBar - 超过2个项目不会进入横向模式

如何在 UITabBar 中显示六个 TabBarItem

UITabbar在iPad和iPhone上出现Chang

iPad 的 UITabBar 弹出窗口中的 UIImagePicker 和相机