iphone用UINavigationController实现在两个页之间导航(下)(5)

来源:未知 责任编辑:责任编辑 发表时间:2013-11-17 14:38 点击:

    // 文字是:美食天地。图像是:UITabBarSystemItemBookmarks 
UITabBarItem *item = [[UITabBarItem alloc] 
                           initWithTitle:@"美食天地" 
                           initWithTabBarSystemItem:UITabBarSystemItemBookmarks 
                          //image:tabImage 
                           tag:0]; 
//本例还注释掉了使用自己的图像shrimp.jpg的两行代码。如你交换一下也能运行 
self.tabBarItem = item; 
    [item release];  
    [super viewDidLoad]; 

- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 
    
    // Release any cached data, images, etc that aren't in use. 

  
- (void)viewDidUnload { 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 

- (void)dealloc { 
    [super dealloc]; 

@end 
//MeiShiTianDi.m原代码结束 

3)、设置视图控制器在标签栏上的标题和图像(UITabBarItem)
每个视图控制器类都有一个UITabBarItem。通过这个类,可以设置视图控制器在标签栏上的标题和图像。标题和图像分为两个类,一类是自己的图像和文字(格式为.png);另一类是系统提供的图像和文字。
首先添加图像到项目中,(在资源文件夹下)
添加UITabBarItem代码到cityViewController.m的viewDidLoad方法下,这里使用用户自己的图像,图像名是:GoldenGateBridge.png
[plain] 
- (void)viewDidLoad { 
//创建一个有边框的文体按钮,按下后,调用视图控制器上的discount方法 
UIBarButtonItem *discountButton = [[UIBarButtonItem alloc] 
                    initWithTitle:@"折扣信息" style:UIBarButtonItemStyleBordered 
                                target:self action:@selector(discount:)]; 
    self.navigationItem.leftBarButtonItem = discountButton;//设置为左边按钮 

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • Lexical or Preprocessor Issue 'xxx.h
  • ios学习笔记(二)xcode 4.3.2下实现基本交互
  • ios版本的helloworld
  • iphone(object-c) 内存管理(3) 有效的内存管理 前半部分
  • ios学习笔记(一)xcode 4.3.2下创建第一个ios项目
  • IOS类似iphone通讯录TableView的完整demo【附源码】
  • UITableView一些方法
  • [iPhone中级]iPhone团购信息客户端的开发 (二)
  • 如何为Iphone应用创建启动界面
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1