3.選擇Objective C class,按下Next鍵。
4. 將類別名稱調整為DLIView2Controller,Subclass of 選擇UIViewController,勾選with XIB for user interface選項,按下Next鍵。
5.選擇Create鍵。
6.點選DLIViewController.xib,放上Button,並建立switch事件程序。
7.輸入程式
DLIViewController.m程式列表如下:
#import "DLIViewController.h"
#import "DLIView2Controller.h"
@interface DLIViewController ()
@end
@implementation DLIViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)switch:(id)sender {
DLIView2Controller *controller = [[DLIView2Controller alloc] initWithNibName:nil bundle:nil];[self presentViewController:controller animated:YES completion:NULL];
}
@end
8.執行結果
9.點選DLIView2Controller.xib增加一個按鈕,建立一個back事件程序。
10.輸入程式
//
// DLIView2Controller.m
// switch
//
// Created by Lin Cheng-Min on 12/10/20.
// Copyright (c) 2012年 Lin Cheng-Min. All rights reserved.
//
#import "DLIView2Controller.h"
#import "DLIViewController.h"
@interface DLIView2Controller ()
@end
@implementation DLIView2Controller
- (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.
}
- (IBAction)back:(id)sender {
DLIViewController *controller = [[DLIViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:controller animated:YES completion:NULL];
}
@end
11.執行結果
沒有留言:
張貼留言