一,效果图。

二,工程图。

三,代码

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
{
UIButton * leftButton;
UIButton * rightButton;
UIViewController * firstController;
UIViewController * secondController; }
@end

RootViewController.m

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. //初始化顶部按钮
[self creatHeadView]; //初始化背景图
[self initBackView]; }
#pragma -mark -functions
//初始化背景图
-(void)initBackView
{
firstController = [[UIViewController alloc] init];
firstController.view.backgroundColor = [UIColor redColor];
[self.view addSubview:firstController.view]; secondController = [[UIViewController alloc] init];
secondController.view.backgroundColor = [UIColor blueColor]; }
//初始化顶部按钮
-(void)creatHeadView
{
UIView * headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)]; //左边的按钮
leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
leftButton.frame = CGRectMake(0, 0, 50, 30);
leftButton.tag = 201;
leftButton.enabled = NO;
[leftButton setImage:[UIImage imageNamed:@"left"] forState:UIControlStateNormal];
[leftButton addTarget:self action:@selector(doClickHeadActions:) forControlEvents:UIControlEventTouchUpInside];
[headView addSubview:leftButton]; //右边的按钮
rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
rightButton.frame = CGRectMake(50, 0, 50, 30);
rightButton.tag = 301;
[rightButton setImage:[UIImage imageNamed:@"right"] forState:UIControlStateNormal];
[rightButton addTarget:self action:@selector(doClickHeadActions:) forControlEvents:UIControlEventTouchUpInside];
[headView addSubview:rightButton]; self.navigationItem.titleView = headView; }
#pragma -mark -doClickActions
-(void)doClickHeadActions:(UIButton *)btn
{
if (btn.tag == 201)
{
[secondController dismissViewControllerAnimated:NO completion:nil];
[self.view addSubview:firstController.view]; [btn setImage:[UIImage imageNamed:@"leftselect"] forState:UIControlStateNormal];
btn.enabled = NO;
[rightButton setImage:[UIImage imageNamed:@"right"] forState:UIControlStateNormal];
rightButton.enabled = YES;
}
else if (btn.tag == 301)
{
[firstController dismissViewControllerAnimated:NO completion:nil];
[self.view addSubview:secondController.view]; [btn setImage:[UIImage imageNamed:@"rightselect"] forState:UIControlStateNormal];
btn.enabled = NO;
[leftButton setImage:[UIImage imageNamed:@"left"] forState:UIControlStateNormal];
leftButton.enabled = YES;
} }
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

【代码笔记】iOS-标题2个图标,点击的时候,页面跳转的更多相关文章

  1. iOS 极光推送 如何点击推送消息跳转页面

    假如你已经集成完了极光,恰好有这个问题不知如何解决,可以看看这篇文章,这篇是针对远程通知的,本地通知大同小异吧. 根据我项目的要求,极光推送跳转指定页面分为两种情况:app在后台情况和app在杀死的情 ...

  2. 【代码笔记】iOS-UITableView上的button点击事件

    代码. ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController < ...

  3. 【代码笔记】iOS-4个可以单独点击的button

    一,效果图. 二,工程图. 三,代码. ViewController.m #import "ViewController.h" @interface ViewController ...

  4. IOS开发笔记 IOS如何访问通讯录

    IOS开发笔记  IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...

  5. IOS APP的所有图标尺寸规范

    转自: http://blog.csdn.net/chonbj/article/details/25133247 像我一样记不住iOS应用图标像素尺寸的开发者不在少数,我经常需要查询不同设备上的应用尺 ...

  6. 【hadoop代码笔记】Mapreduce shuffle过程之Map输出过程

    一.概要描述 shuffle是MapReduce的一个核心过程,因此没有在前面的MapReduce作业提交的过程中描述,而是单独拿出来比较详细的描述. 根据官方的流程图示如下: 本篇文章中只是想尝试从 ...

  7. 【hadoop代码笔记】hadoop作业提交之汇总

    一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...

  8. 【Hadoop代码笔记】目录

    整理09年时候做的Hadoop的代码笔记. 开始. [Hadoop代码笔记]Hadoop作业提交之客户端作业提交 [Hadoop代码笔记]通过JobClient对Jobtracker的调用看详细了解H ...

  9. 笔记-iOS 视图控制器转场详解(上)

    这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...

  10. <Python Text Processing with NLTK 2.0 Cookbook>代码笔记

    如下是<Python Text Processing with NLTK 2.0 Cookbook>一书部分章节的代码笔记. Tokenizing text into sentences ...

随机推荐

  1. LINQ使用Lambda表达式选择几列

    学习LINQ的Lambda的表达式,尝试从数据集合中,选择其中几列. 创建一个model: source code: namespace Insus.NET.Models { public class ...

  2. winform自定义日期控件,要求可以手动输入日期DatePicker

    要求:文本框中能手动输入数字,向上箭头根据鼠标位置给年月日递增,向下箭头递减 一:页面加载时: private void FlatDatePicker_Load(object sender, Even ...

  3. jquery输入数字随机抽奖特效

    简介:jQuery自定义数值抽奖活动代码是一款点击开始按钮计算机会产生玩家输入范围内的随机数,点击停止按钮,将显示数字最终结果的效果. 效果展示 http://hovertree.com/texiao ...

  4. iOs 自定义UIView 日历的实现 Swift2.1

    学习Swift有一个月了,动手写一个UIView吧. 所有源代码在最后,直接用就可以了,第一次写Swift,和C#,Java还是有区别的 (博客园可以考虑在代码插入中添加Swift的着色了) 1  函 ...

  5. 不可或缺 Windows Native (17) - C++: 类与对象

    [源码下载] 不可或缺 Windows Native (17) - C++: 类与对象 作者:webabcd 介绍不可或缺 Windows Native 之 C++ 类与对象 示例1.类的设计CppE ...

  6. 后缀名为properties,config和xml的文件内容读取

    1.先建立文件(后缀名为properties和config) 2.读取类建立 public class Read{ public static Properties  properties = new ...

  7. ACm-ICPC Live Archive 7464---Robots

    ACm-ICPC Live Archive 7464---Robots Write a program to collect data from robots. We are given two se ...

  8. AppleDoc的安裝使用

    前言,還是那句話,新手按照濤叔下面畫黃色的步驟順序執行就好了,不要問為什麼. 一.安裝(注意,濤叔事先已經下載了appledoc) 1.找到下載的appledoc目錄 $ cd /Users/libo ...

  9. ssh架构简单解释和vo po解释

      Struts.spring.Hibernate在各层的作用 1)struts 负责 web层. ActionFormBean 接收网页中表单提交的数据,然后通过Action 进行处理,再Forwa ...

  10. Java空白final

    Java 1.1允许我们创建"空白final",它们属于一些特殊的字段.尽管被申明为final,但却未得到一个初始值. 无论在哪种情况下,空白final都必须在实际使用前得到正确的 ...