- 浏览: 2966968 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (893)
- android (110)
- iphone (198)
- java (79)
- JavaScript手册-目录 (9)
- JavaScript手册-Array (19)
- JavaScript手册-Boolean (5)
- JavaScript手册-Date (50)
- JavaScript手册-Math (30)
- JavaScript手册-Number (14)
- JavaScript手册-RegExp (7)
- JavaScript手册-String (38)
- JavaScript手册-全局函数 (8)
- JavaScript实用脚本 (7)
- Others (21)
- java-jpcap (7)
- java-thread (1)
- ibm文章 (3)
- classloader (2)
- java-filter (2)
- 运行环境 (33)
- java-正则 (2)
- oracle (1)
- linux-shell (26)
- wap (1)
- sqlite (3)
- wow (1)
- jvm (1)
- git (5)
- unity3d (29)
- iap (2)
- mysql (23)
- nginx (14)
- tomcat (9)
- apache (2)
- php (1)
- ubuntu (40)
- rsa (1)
- golang (21)
- appstore (5)
- sftp (2)
- log4j (2)
- netty (18)
- 测试工具 (6)
- memcache (5)
- 设计模式 (1)
- centos (8)
- google_iab (5)
- iOS专题 (4)
- mac (10)
- 安装配置帮助手册 (2)
- im4java_graphicsmagick (5)
- inotify-tools (1)
- erlang (6)
- 微信支付 (1)
- redis (8)
- RabbitMQ (5)
最新评论
-
heng123:
Netty视频教程https://www.douban.com ...
netty4.0.23 初学的demo -
maotou1988:
使用Netty进行Android与Server端通信实现文字发 ...
netty4.0.23 初学的demo -
码革裹尸:
非常感谢,正好用上
android 呼入电话的监听(来电监听) -
rigou:
提示的/222.177.4.242 无法链接到ip地址,是什 ...
通过 itms:services://? 在线安装ipa ,跨过app-store -
duwanbo:
GridView与数据绑定
如何从当前窗口界面切换到另一个窗口界面
在程序中,经常会在不同的窗口界面中互相切换。本文,将介绍如何进行窗口界面的切换。
下面采用的示例以文章《在程序代码中设定控件调用的方法 》代码为基础。
操作处理过程:
(1)新建一个窗口视图;
(2)调用打开新建的窗口视图;
第1步:新建一个窗口视图
鼠标选中项目的classes目录,鼠标右键选中菜单 [Add > New File...].
在界面上选择[iOS > Cocoa Touch Class > UIViewController subclass ],并且选中 With XIB for user interface.
新建的视图取名为 NewViewController .
打开文件 NewViewController.xib ,在界面上增加一个按钮(标题设为 back)。
修改 NewViewController.h 文件:
#import <UIKit/UIKit.h>
@interface NewViewController : UIViewController {
}
-(IBAction)backButtonClicked:(id)sender;
@end
修改 NewViewController.m 文件:
#import "NewViewController.h"
@implementation NewViewController
-(IBAction)backButtonClicked:(id)sender{
[self.view removeFromSuperview];
}
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
}
return self;
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (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
@implementation NewViewController
-(IBAction)backButtonClicked:(id)sender{
[self.view removeFromSuperview];
}
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
}
return self;
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (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
然后,在 NewViewController.xib 中将按钮控件的点击事件绑定方法backButtonClicked。
第2步:调用打开新建的窗口视图;
修改 FirstViewController.m 文件:
#import "FirstViewController.h"
#import "NewViewController.h"
@implementation FirstViewController
NewViewController *newViewController;
@synthesize label,button;
-(IBAction)myButtonClicked:(id)sender{
newViewController=[[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
[self.view addSubview:newViewController.view];
/*
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"my alert"
message:@"button is clicked"
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
[alert release];
*/
}
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
//create the label
CGRect frame=CGRectMake(50, 30, 200, 45);
label=[[UILabel alloc] initWithFrame:frame];
label.text=@"This is a label";
//create the button
frame=CGRectMake(50, 100, 200, 45);
button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame=frame;
[button setTitle:@"OK" forState:UIControlStateNormal];
[button addTarget:self
action:@selector(myButtonClicked:)
forControlEvents:UIControlEventTouchUpInside];
//add the label and button into current view.
[self.view addSubview:label];
[self.view addSubview:button];
[super viewDidLoad];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (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 {
[newViewController release];
[label release];
[button release];
[super dealloc];
}
@end
#import "NewViewController.h"
@implementation FirstViewController
NewViewController *newViewController;
@synthesize label,button;
-(IBAction)myButtonClicked:(id)sender{
newViewController=[[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
[self.view addSubview:newViewController.view];
/*
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"my alert"
message:@"button is clicked"
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
[alert release];
*/
}
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
//create the label
CGRect frame=CGRectMake(50, 30, 200, 45);
label=[[UILabel alloc] initWithFrame:frame];
label.text=@"This is a label";
//create the button
frame=CGRectMake(50, 100, 200, 45);
button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame=frame;
[button setTitle:@"OK" forState:UIControlStateNormal];
[button addTarget:self
action:@selector(myButtonClicked:)
forControlEvents:UIControlEventTouchUpInside];
//add the label and button into current view.
[self.view addSubview:label];
[self.view addSubview:button];
[super viewDidLoad];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (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 {
[newViewController release];
[label release];
[button release];
[super dealloc];
}
@end
执行后,点击界面上的[OK]按钮,即显示新建的窗口视图;再点击新窗口视图的[back]按钮,即显示前一窗口。
发表评论
-
iOS程序运行生命周期
2015-11-10 09:05 966iOS程序运行生命周期 在文件AppDele ... -
iOS开发系列--IOS程序开发概览
2015-11-10 07:32 1181iOS开发系列--IOS程序开发概览 概览 ... -
2015年11月Xcode7.1(7B91b)打包发布苹果iOS应用指南
2015-11-09 18:29 108862015年11月Xcode7.1(7B91b) ... -
self.navigationController pushViewController执行不成功
2015-11-06 08:28 1614self.navigationControlle ... -
ios NSString format 保留小数点 float double
2015-11-05 17:37 2934ios NSString format 保留小数点 f ... -
自定义 URL Scheme 完全指南
2015-11-04 16:21 904自定义 URL Scheme 完全指南 转载 htt ... -
UIViewController生命周期方法viewDidLoad、viewWillAppear和viewDidAppear
2015-11-01 12:29 2957UIViewController生命周期 ... -
关于self.view.window与viewDidLoad、viewWillAppear、viewDidAppear
2015-11-01 09:36 2543关于self.view.window与viewD ... -
UIScreen学习记录
2015-10-31 08:18 1061UIScreen学习记录 转载自 ... -
使用NSTimer和CGAffineTransformMakeRotation实现旋转动画
2015-10-29 11:53 1827使用NSTimer和CGAffineTransform ... -
【原】iOSCoreAnimation动画系列教程(一):CABasicAnimation【包会】
2015-10-29 08:59 1026【原】iOSCoreAnimation动 ... -
iOS 在UILabel显示不同的字体和颜色
2015-10-27 08:07 1559在项目开发中,我们经常会遇到在这样一种情形:在一个UI ... -
UISlider滑动条的属性介绍以及于标签联合使用实时显示变动值
2015-10-27 08:06 1257UISlider滑动条的属性 ... -
关于使用DSLTableView下拉刷新数据遇到的问题
2015-10-23 21:17 943关于使用DSLTableView下 ... -
使用AdSupport.framework生成IDFA唯一标识符
2015-10-23 17:29 4710使用AdSupport.framework生成IDFA ... -
AppDelegate的详解
2015-10-22 17:51 680AppDelegate的详解 ... -
iOS开发问题集锦
2015-10-22 13:06 5301. Xcode开发连真机运行报错Please ver ... -
iOS 对象属性参数名定义的注意事项不能以alloc,new,copy,mutableCopy 作为开头命名
2015-10-21 15:41 1327property's synthesized g ... -
iOS-自定义的画圆或弧的UIView
2015-10-21 14:20 2656iOS-自定义的画圆或弧的UIView Cu ... -
iOS自定义的模态提示对话框
2015-10-20 14:27 6478iOS自定义的模态提示对话框 基本思路: 1.创建 ...
相关推荐
# PyQt5实现单窗口多界面切换 多选项卡示例程序 1. 在窗口中创建选项卡组件,可以包含多个界面; 2. 对每个界面分别定义界面内容; 3. 点击选项卡标签即可切换界面。
基于Python和PyQt5实现同一窗口下多界面切换
Qt 两个窗口相互切换,Qt信号与槽的机制,实现两个窗口通过点击按钮完成互相切换 Qt 两个窗口相互切换,Qt信号与槽的机制,实现两个窗口通过点击按钮完成互相切换
一个简单的利用信号-槽实现的界面跳转切换示例
同一个界面多窗口或者多页面切换(QStackedWidget)简单示例
在很多时候我们希望在一个窗口中或者一个自定义的QWidget中实现多个窗口的实现,以此来实现当功能太多时不局限于每次单独创建其窗口去显示功能模块,写了一个简单例子
利用QTimeLine实现点击按钮后,窗口不是弹出,而是从右侧划入当前的界面内。
该资源里面有一个可以实现点击一个窗口弹出另一个窗口的实例,还有一个本人在解决这个问题时所做的笔记。你们可对比实例和我的笔记来参考。
VS2013基于MFC简单的界面切换,适用于初学者,高手就不要下载了
demo主要采用信号与槽函数的方式对两个界面进行了不同切换,自定义按钮方式,子窗口与主窗口点击切换。该代码中涉及的技术有1.自定义函数类,在主函数中实例化。2.通过信号与槽在不同类中建立联系,在子类中定义信号...
SeggerEval_WIN32_MSVC_MinGW_GUI_V528_002多个页面窗口切换
有A,B,C三个界面,每个界面上分别有一个按钮,点击按钮就会切换到另一个界面上,同时当前界面隐藏,具体效果顺序:A-->B-->C-->A;前一篇实现的是2个窗口的切换,可能很多人不一定能真正的理解信号槽在多窗口切换的...
实现类似 C# TabControl 控件的效果,在同一区域实现界面的切换。通过ContentControl , Frame , Page等将生成子界面嵌入到主窗口。
让XP拥有比win7更炫的3D窗口切换特效让XP拥有比win7更炫的3D窗口切换特效让XP拥有比win7更炫的3D窗口切换特效让XP拥有比win7更炫的3D窗口切换特效让XP拥有比win7更炫的3D窗口切换特效让XP拥有比win7更炫的3D窗口切换...
基于pyqt5 基础功能 包含两个界面:主界面、二界面
C#winform窗口切换,感觉很好玩,而且玩起来蛮炫的,适合初学者。用到API
vc技术,多窗口自由切换,在vc6.0已经测试通过。
使用WPF的Frame+Page组合多个界面,用NavigationService实现界面切换。压缩包中包含一个简单的示例,包括主窗口(包含Frame),选择下一步的Page(Frame的初始窗口)和两个“下一步”的目标Page。
C#窗口切换源代码,水平、垂直翻转和透明过渡等效果源码