IBOutlet / IBAction

iOS 2012. 3. 7. 13:53
반응형
참고: http://www.bestechvideos.com/2012/02/28/learning-ios-development-part-5-iboutlet-and-ibaction
 

//

//  smilejsuViewController.h

//  HelloWorld2

//

//  Created by sang wook Jang on 12. 3. 7..

//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.

//


#import <UIKit/UIKit.h>


@interface smilejsuViewController : UIViewController

{

    IBOutlet UITextField *tf;

    IBOutlet UILabel *lb;

}


@property (nonatomic, retain) UITextField *tf;

@property (nonatomic, retain) UILabel *lb;


-(IBAction)button_touched:(id)sender;


@end



//

//  smilejsuViewController.m

//  HelloWorld2

//

//  Created by sang wook Jang on 12. 3. 7..

//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.

//


#import "smilejsuViewController.h"


@interface smilejsuViewController ()


@end


@implementation smilejsuViewController

@synthesize tf, lb;


- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

}


- (void)viewDidUnload

{

    [super viewDidUnload];

    // Release any retained subviews of the main view.

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);

}


- (IBAction) button_touched:(id)sender

{

    [lb setText:[tf text]];

}


@end




outlet을 이용해서 연결해준다.


결과
 
반응형

'iOS' 카테고리의 다른 글

Cocos2D 기초 강좌  (0) 2012.03.07
Cocos2D example  (0) 2012.03.07
여러대 맥에서 iOS개발시 인증서 복사  (0) 2012.03.07
XCode 4.3 + iOS 5.0 HelloWorld  (0) 2012.03.07
XCode 4.3 시뮬레이터 재시작되는 이유  (0) 2012.03.07
: