一,效果图。

二,工程图。

三,代码。

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. 完美且精准的 IE10- 版本检测。

    通过动态的写入条件注释的方式,来判断当前的ie浏览器的版本,优点是,对比userAgent字符匹配,要精准很多,应该说是100%正确,缺点就是要通过JS写入条件注释,拖慢页面的加载速度. 如果对于只判 ...

  2. C语言学习002:第一个完整的C程序代码

    #include <stdio.h>//引用相关的外部库,stdio.h包含了终端读写数据的代码 //程序入口,程序通过main函数的返回值判断程序是否运行成功,0表示成功,非0表示程序运 ...

  3. Web API应用架构设计分析(1)

    Web API 是一种应用接口框架,它能够构建HTTP服务以支撑更广泛的客户端(包括浏览器,手机和平板电脑等移动设备)的框架, ASP.NET Web API 是一种用于在 .NET Framewor ...

  4. javascript事件分类解析

    最近在学习javascript,就顺便把常用事件给大家整理整理,也让自己加深印象.不足之处欢迎各位补充. 一般事件 onclick 鼠标点击时触发此事件 ondblclick  鼠标双击时触发此事件 ...

  5. ASP.NET Core开发-读取配置文件Configuration

    ASP.NET Core 是如何读取配置文件,今天我们来学习. ASP.NET Core的配置系统已经和之前版本的ASP.NET有所不同了,之前是依赖于System.Configuration和XML ...

  6. UML类图

    类 类图分三层,第一层显示类的名称,如果是抽象类,那就用斜体显示.第二层是类的特性,通常就是字段和属性.第三类是类的操作,通常是方法或行为.注意前面的符号,‘ +’表示public ,‘-’表示 pr ...

  7. MVP 2015社区大讲堂之:在ASP.NET应用中执行后台任务

    昨天下午,在微软的MVP 2015社区大讲堂上给大家分享了一个题目:在ASP.NET应用中执行后台任务.这是一点都不高大上,并且还有点土气的技术分享.不过我相信很多人都遇到过这样的问题. 虽然是一个很 ...

  8. csharp:using OpenXml SDK 2.0 and ClosedXML read excel file

    https://openxmlexporttoexcel.codeplex.com/ http://referencesource.microsoft.com/ 引用: using System; u ...

  9. 【Java每日一题】20161109

    package Nov2016; import java.lang.reflect.Method; public class Ques1109 { public static void main(St ...

  10. hibernate简单注释(一)

    *****************************hibernate.cfg.xml************************************ <?xml version= ...