TabBar的使用,一个应用程序中,tablebar始终存在于界面下方
来源:互联网 发布:uml数据库表示法 编辑:程序博客网 时间:2024/05/05 21:47
如果你想做一个类似于满座的下面的tablebar下面的功能,
那么恭喜你找对了,直接上代码
首先在AppDelegate.h里面添加以下代码
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate,UITabBarDelegate,UITabBarControllerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property(nonatomic,retain)UITabBarController*tabBarController;
@end
然后在AppDelegate.m
导入所创建类的头文件
然后在
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]] autorelease];
_tabBarController=[[UITabBarControlleralloc]init];
_tabBarController.delegate=self;
MainViewController*first=[[MainViewControlleralloc]init];
first.tabBarItem.title=@"主页";
first.tabBarItem.image=[UIImageimageNamed:@"a.png"];
NearViewController *second=[[NearViewControlleralloc]init];
second.tabBarItem.title=@"周边";
second.tabBarItem.image=[UIImageimageNamed:@"c.png"];
SearchViewController*third=[[SearchViewControlleralloc]init];
third.tabBarItem.title=@"搜索";
third.tabBarItem.image=[UIImageimageNamed:@"e.png"];
AppSetingViewController*fourth=[[AppSetingViewControlleralloc]init];
fourth.tabBarItem.title=@"满座";
fourth.tabBarItem.image=[UIImageimageNamed:@"s.png"];
UINavigationController * nav1 =[[UINavigationControlleralloc]initWithRootViewController:first];
UINavigationController * nav2 =[[UINavigationControlleralloc]initWithRootViewController:second];
UINavigationController * nav3 =[[UINavigationControlleralloc]initWithRootViewController:third];
UINavigationController * nav4 =[[UINavigationControlleralloc]initWithRootViewController:fourth];
NSArray * nsa =[[NSArrayalloc]initWithObjects:nav1,nav2,nav3,nav4,nil];
_tabBarController.viewControllers=nsa;
self.window.rootViewController=_tabBarController;
[first release];
[second release];
[third release];
[fourth release];
[nav1 release];
[nav2 release];
[nav3 release];
[nav4 release];
[nsa release];
self.window.backgroundColor = [UIColorwhiteColor];
[self.windowmakeKeyAndVisible];
return YES;
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
}
添加以下的代码,就可以实现上述功能了,小弟是ios初学者,可能有些地方描述不准确,代码书写不规范,希望各位大牛勿喷,同时希望给予指导和帮助。
写这篇博客就是自己的一个随身笔记,希望对各位有所帮助。
- TabBar的使用,一个应用程序中,tablebar始终存在于界面下方
- iOS中跳转到一个tabbar对应的界面时,tabbar联动效果
- 让页脚始终在页面的最下方
- tabbar下方的红色提示图标
- 仿微信或QQ下方的TabBar
- [C#]租约的Renew和“在主机应用程序域运行时始终”将对象保存在内存中
- [C#]租约的Renew和“在主机应用程序域运行时始终”将对象保存在内存中
- [C#]租约的Renew和“在主机应用程序域运行时始终”将对象保存在内存中
- iOS进入界面隐藏下方tabbar等bar
- iOS进入界面隐藏下方tabbar等bar
- C#中,如何让richTextBox旁边的滚动条始终处于最下方
- html中怎么样让textarea的滚动条始终在最下方
- C#中让RichTextBox控件的垂直滚动条始终位于最下方
- 使用div+CSS将页脚始终控制在页面最下方的方法
- MFC中如何去掉CPropertySheet界面下方的四个按钮?
- MFC中如何去掉CPropertySheet界面下方的按钮
- 让网页的页脚始终待在最下方
- tableBar 嵌套NavGationController 无法使用手势返回的问题
- 一位资深HR的职场感言
- iOS开发视频教程 UI部分:7.模拟器常用操作
- string和stringBuilder区别
- 计算机科学精彩帖子收集
- 连续的数字取中断的编写思路,希望有更好的方式
- TabBar的使用,一个应用程序中,tablebar始终存在于界面下方
- loadrunner录入脚本有乱码解决方法
- myeclipse安装svn
- 浏览器表标准符合性测试实践
- 调试ExtJs利器之Full Source(IE插件)
- 大数据时代催生计算社会科学
- myeclipse10 中的项目无法部署到tomcat6.x安装版
- WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用
- bash参考手册之零(bash特性)