一,效果图。

二,工程图。

三,代码。

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController

@end

RootViewController.m

#import "RootViewController.h"
#import "DetailViewController.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 creatSearchBar];
}
#pragma -mark -functions
-(void)creatSearchBar
{
UIImageView * searchView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search"]];
searchView.frame = CGRectMake(0, 80, 320, 40);
searchView.userInteractionEnabled = YES;
[self.view addSubview:searchView]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] init];
tap.numberOfTouchesRequired = 1;
[tap addTarget:self action:@selector(searchViewPress:)];
[searchView addGestureRecognizer:tap]; UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 200, 20)];
titleLabel.text = @"搜索";
titleLabel.font = [UIFont systemFontOfSize:12];
[searchView addSubview:titleLabel]; }
#pragma -mark -doClickActions
-(void)searchViewPress:(UIGestureRecognizer *)tap
{
DetailViewController *detail=[[DetailViewController alloc]init];
[self.navigationController pushViewController:detail animated:NO];
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

DetailViewController.h

#import <UIKit/UIKit.h>

@interface DetailViewController : UIViewController

@end

DetailViewController.m

#import "DetailViewController.h"

@interface DetailViewController ()

@end

@implementation DetailViewController

- (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.
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

【代码笔记】iOS-点击搜索跳转到另外一个页面的更多相关文章

  1. 如何绑定android点击事件--跳转到另一个页面并实现关闭功能?

    一.点击按钮跳转到另一个页面. eg:实现从一个页面点击跳转到另一个页面 1.首先在一个布局文件(.XML)中绘画了一个跳转按钮(id为btn1): <Button         androi ...

  2. 【代码笔记】iOS-点击搜索按钮,或放大镜后都会弹出搜索框

    一, 效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "CLHSearchBar.h ...

  3. 【代码笔记】iOS-点击城市中的tableView跳转到旅游景点的tableView,下面会有“显示”更多。

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  4. 作用域通信对象:session用户在登录时通过`void setAttribute(String name,Object value)`方法设置用户名和密码。点击登录按钮后,跳转到另外一个页面显示用户

    作用域通信对象:session session对象基于会话,不同用户拥有不同的会话.同一个用户共享session对象的所有属性.作用域开始客户连接到应用程序的某个页面,结束与服务器断开连接.sessi ...

  5. 解决TabActivity中子页面不通过导航跳转到还有一个页面的问题

    问题:当你的导航在TabActivity中 而子页面的一个button须要切换到当中的某一个导航页面 转载请注明出处:http://blog.csdn.net/x605940745 demo下载地址: ...

  6. 基于jquery的从一个页面跳转到另一个页面的指定位置的实现代码

    比如 想跳到 mao.aspx 的页面 的div id="s" 的位置 那么 只用<a href="mao.aspx#s"> 就可实现跳转到指定位置 ...

  7. jsp中点击一个图片跳转到另一个页面的方法

    1.这是jsp页面中的关于图片的那段代码 <img src="images/tj1.png " id="tj1"></img> 2.跳转 ...

  8. PHP 页面跳转到另一个页面的几种方法分享

    如何在 PHP 中从一个页面重定向到另外一个页面呢?今天 清源 为大家列举出了三种办法,供大家来参考. 一.用HTTP头信息  也就是用PHP的HEADER函数.PHP里的HEADER函数的作用就是向 ...

  9. PHP 页面跳转到另一个页面的多种方法方法总结

    如何在PHP中从一个页面重定向到另外一个页面呢?这里列出了三种办法,供参考. 一.用HTTP头信息 也就是用PHP的HEADER函数.PHP里的HEADER函数的作用就是向浏览器发出由HTTP协议规定 ...

随机推荐

  1. final .....finally ...... 和Finalize ......区别

    一.性质不同 ()final为关键字: ()finalize()为方法: ()finally为为区块标志,用于try语句中: 二.作用 ()final为用于标识常量的关键字,final标识的关键字存储 ...

  2. Log4net 日志使用介绍

    概述 Log4net 有三个主要组件:loggers,appenders 和 layouts.这三个组件一起工作使得开发者能够根据信息类型和等级(Level)记录信息,以及在运行时控制信息的格式化和信 ...

  3. 基础复习 关于JS

    1,js是一门解释型语言,无需编译,编写js要知道当前对象有什么成员,未必所有成员都能点出来. 2,js大小写敏感,严格区分大小写. 3,弱类型语言,声明用var,字符串推荐使用单引号. 4,==要先 ...

  4. SQL更改表字段为自增标识

    下面是SQL语句: --删除主键约束 ) select @Constraint_Name = Name from dbo.sysobjects where Xtype = 'PK' and Paren ...

  5. dmesg 的时间戳处理

    dmesg_with_human_timestamps () { $(type -P dmesg) "$@" | perl -w -e 'use strict; my ($upti ...

  6. Java集合源码分析(五)HashSet<E>

    HashSet简介 HashSet实现Set接口,由哈希表(实际上是一个HashMap实例)支持.它不保证set 的迭代顺序:特别是它不保证该顺序恒久不变.此类允许使用null元素. HashSet源 ...

  7. java 基础加强--书籍+题目+上机测试

    scjp test( 在线测试网站):http://scjptest.com/mock-test.xhtml <SCJP Sun® Certified Programmer for Java™ ...

  8. java集合-hashCode

    hashCode 的作用 在 Java 集合中有两类,一类是 List,一类是 Set 他们之间的区别就在于 List 集合中的元素师有序的,且可以重复,而 Set 集合中元素是无序不可重复的.对于 ...

  9. web桌面程序之图标拖动排序的分析

    在web桌面程序里,图标拖动并重新排序是个比较常见的功能.这个功能我之前反复修改了好几遍,现在终于整理出了比较理想的解决思路,决定拿出来分享下. 这一功能主要有哪些难点呢?我总结了一下一共有2处难点: ...

  10. IClient for js开发之地图的加载

    进行web开发之前首先需要安装IServer以及iClient for JavaScript的开发包.在这两中都具备的前提下进行第一步,如何调用IServer中发布的服务 调用iServer 中发布的 ...