首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序)

2013-01-28 
008 在Xcode4.5上创建IOS6.0应用 (多视图应用程序)根视图应用程序(两个视图之间的切换)在IOS上做多视图的

008 在Xcode4.5上创建IOS6.0应用 (多视图应用程序)

根视图应用程序(两个视图之间的切换)在IOS上做多视图的切换是个比较重要的东西,也是一个要重点了解的知识点。在iOS下开发的程序基本上所有的都是有多个视图,下面我就带大家一起来创建一个多视图的应用首先让我们看看实际运行的效果图008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序)008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序)
008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序)008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序)
通过点击下面的切换视图按钮来达到视图切换的目的

目录大纲008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序)

创建两个不同的视图
第一步:选择Group点击右健选择 new File008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序)

第二步:选择iOS下面的CocoaTouch然后是Object_C 点击下一步008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序) 
第三步:创建 点击下一步完成008 在Xcode4.5下创建IOS6.0应用 (多视图应用程序)
Class写一个自己的类明SubClass of 中有很多的选择项,这里我们要选择UIViewController这个对象注意:记得钩上With XIB for user interface 选项
下面就只要设计界面,然后完善视图就OK啦只要按照下面的代码然后执行就可以看到上面的效果ViewController.h注意在主视图的H文件中要记得引入两个子视图控件的H文件

#import "YellowViewController.h"

#import "BlueViewController.h"


@implementation BlueViewController-(IBAction)blueclick:(id)sender{    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"紧急提示"                                                     message:@"亲爱的我想你."                                                    delegate:nil                                           cancelButtonTitle:@"想你妹"                                           otherButtonTitles:@"我也想你", nil];    [alert show];    [alert release];}- (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 from its nib.}- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}@end


这样一来我们的多视图应用程序就完成啦。

1楼whui0110前天 11:10
你好,请问你的主界面和上面的View Controller怎么拖拽生成的。

热点排行