ページ

2011年5月30日月曜日

iPhoneでviewをswitchする





viewSwitcherViewController.h
#import <UIKit/UIKit.h>

@interface viewSwitcherViewController : UIViewController {

}

-(IBAction) next:(id) sender;

@end


viewSwitcherViewController.m
#import "viewSwitcherViewController.h"
#import "SecondViewController.h"


@implementation viewSwitcherViewController

-(IBAction) next:(id) sender{
 SecondViewController *second = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
 [self presentModalViewController:second animated:YES];
}

- (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 {
 // Release any retained subviews of the main view.
 // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end

SecondViewController.h
#import <UIKit/UIKit.h>


@interface SecondViewController : UIViewController {

}

-(IBAction) previous:(id) sender;

@end


SecondViewController.m
#import "SecondViewController.h"
#import "viewSwitcherViewController.h"

@implementation SecondViewController

-(IBAction) previous:(id) sender{
 viewSwitcherViewController *first = [[viewSwitcherViewController alloc] initWithNibName:nil bundle:nil];
 [self presentModalViewController:first animated:YES];
}

- (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


参考

YouTube - iPhone SDK Tutorial: Switching Views
http://www.youtube.com/watch?v=IrPPymeYyyU&hd=1

0 件のコメント:

コメントを投稿