【代码笔记】iOS-标题2个图标,点击的时候,页面跳转
一,效果图。
二,工程图。
三,代码
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个图标,点击的时候,页面跳转的更多相关文章
- iOS 极光推送 如何点击推送消息跳转页面
假如你已经集成完了极光,恰好有这个问题不知如何解决,可以看看这篇文章,这篇是针对远程通知的,本地通知大同小异吧. 根据我项目的要求,极光推送跳转指定页面分为两种情况:app在后台情况和app在杀死的情 ...
- 【代码笔记】iOS-UITableView上的button点击事件
代码. ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController < ...
- 【代码笔记】iOS-4个可以单独点击的button
一,效果图. 二,工程图. 三,代码. ViewController.m #import "ViewController.h" @interface ViewController ...
- IOS开发笔记 IOS如何访问通讯录
IOS开发笔记 IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...
- IOS APP的所有图标尺寸规范
转自: http://blog.csdn.net/chonbj/article/details/25133247 像我一样记不住iOS应用图标像素尺寸的开发者不在少数,我经常需要查询不同设备上的应用尺 ...
- 【hadoop代码笔记】Mapreduce shuffle过程之Map输出过程
一.概要描述 shuffle是MapReduce的一个核心过程,因此没有在前面的MapReduce作业提交的过程中描述,而是单独拿出来比较详细的描述. 根据官方的流程图示如下: 本篇文章中只是想尝试从 ...
- 【hadoop代码笔记】hadoop作业提交之汇总
一.概述 在本篇博文中,试图通过代码了解hadoop job执行的整个流程.即用户提交的mapreduce的jar文件.输入提交到hadoop的集群,并在集群中运行.重点在代码的角度描述整个流程,有些 ...
- 【Hadoop代码笔记】目录
整理09年时候做的Hadoop的代码笔记. 开始. [Hadoop代码笔记]Hadoop作业提交之客户端作业提交 [Hadoop代码笔记]通过JobClient对Jobtracker的调用看详细了解H ...
- 笔记-iOS 视图控制器转场详解(上)
这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...
- <Python Text Processing with NLTK 2.0 Cookbook>代码笔记
如下是<Python Text Processing with NLTK 2.0 Cookbook>一书部分章节的代码笔记. Tokenizing text into sentences ...
随机推荐
- 十年微软(Microsoft)MVP
十年微软(Microsoft)MVP,七月一日收到邮件,今早收到从美国微软寄过来的证书!
- Winform开发框架之存储过程的支持--存储过程的实现和演化提炼(2)
本篇继续上篇<Winform开发框架之存储过程的支持--存储过程的实现和演化提炼(1)>来对Winform开发框架之存储过程的支持进行介绍,上篇主要介绍了SQLServer和Oracle两 ...
- MySQL性能优化的20条经验
今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我 们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数 ...
- PHP面试题汇总
1.用PHP打印出前一天的时间格式是2014-01-13 12:10:21(2分) 2.echo(),print(),print_r()的区别(3分) 3.能够使HTML和PHP分离开使用的模板(1分 ...
- Windows Server 2008 R2 负载平衡入门篇
一.简单介绍负载均衡 负载均衡也称负载共享,它是指负载均衡是指通过对系统负载情况进行动态调整,把负荷分摊到多个操作节点上执行,以减少系统中因各个节点负载不均衡所造成的影响,从而提高系统的工作效率.在常 ...
- ASP.NET MVC中使用Dropzone.js实现图片的批量拖拽上传
说在前面 最近在做一个MVC相册的网站(这里),需要批量上传照片功能,所以就在网上搜相关的插件,偶然机会发现Dropzone.js,试用了一下完全符合我的要求,而且样式挺满意的,于是就在我的项目中使用 ...
- hibernate----1-1-----两表关联属性放在另一个表里面
package com.ij34.dao; import javax.persistence.*; @Entity @Table(name="Address_inf") publi ...
- MVC-自定义HttpModule处理
HttpModule是向实现类提供模块初始化和处置事件. 当一个HTTP请求到达HttpModule时,整个ASP.NET Framework系统还并没有对这个HTTP请求做任何处理,也就是说此时对于 ...
- 2016暑假多校联合---Death Sequence(递推、前向星)
原题链接 Problem Description You may heard of the Joseph Problem, the story comes from a Jewish historia ...
- PhantomJS快速入门
本文简要介绍了PhantomJS的相关基础知识点,主要包括PhantomJS的介绍.下载与安装.HelloWorld程序.核心模块介绍等.由于鄙人才疏学浅,难免有疏漏之处,欢迎指正交流. 1.Phan ...