본문 바로가기

개발/App Developer

UITextView keyBoard

 

보드 숨기는 기능이 실행이 안되는데 고수님들의 조언 부탁드립니다.

리턴키를 누르면 잘 실행되는데 화면 다른곳 클릭했을때도 키보드를 숨기고 싶어서

iphone SDK3.0책을 보고 따라해서 성공을 했었는데 코딩을 추가하는 중에 

어느순간부터 실행이 안되네요... 고수님들의 조언 부탁드립니다.



헤더파일

#import <UIKit/UIKit.h>


@interface InformationController : UIViewController <UIScrollViewDelegate,

  UITextFieldDelegate> {

    IBOutlet UIScrollView *scrollView;

IBOutlet UIScrollView *scrollView1;

IBOutlet UITextField *nameField;

  UIButton *save;

  UIButton *cancle;

}

@property (nonatomic,retainIBOutlet UIButton *save;

@property (nonatomic,retainIBOutlet UIButton *cancle;


-(IBAction) onBackground:(id)sender;

-(IBAction) onSegmentChanged:(id)sender;

-(IBAction) onSave:(id)sender;

-(IBAction) onCancle:(id)sender;



@end


m파일

#import "InformationController.h"

#import "SearchController.h"

#import "CustomController.h"



@implementation InformationController


@synthesize save;

@synthesize cancle;


-(IBAction) onSegmentChanged:(id)sender {

int sel  = [sender selectedSegmentIndex];

[scrollView setHidden:(sel==0)];

[scrollView1 setHidden:(sel==1)];

}


-(void)viewDidLoad {

[super viewDidLoad];

}


-(void)viewWillAppear:(BOOL)animated {

}


-(BOOL)textFieldShouldReturn:(UITextField *)textField {

[textField resignFirstResponder];

return YES;

}


-(IBAction)onBackground:(id)sender{

NSArray *subs = self.view.subviews;

id curView;

for(curView in subs){

if([curViewconformsToProtocol:@protocol(UITextInputTraits)]){

[curView resignFirstResponder];

}

}

}


-(IBAction) onSave:(id)sender{

SearchController* search = [[SearchController alloc

   initWithNibName:@"SearchController"bundle:nil];

[self.navigationController pushViewController:search animated:YES];

[search release];

}


-(IBAction) onCancle:(id)sender{

    

}



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

[nameField release];

    [super dealloc];

}



@end




onBackground가 뭐하는 건지는 잘 모르겠는데요..

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    
    UITouch *theTouch = [touches anyObject];
    CGPoint tapPoint = [theTouch locationInView:self.view.subviews];

    if( !CGRectContainsPoint(curView.frame, tapPoint) ) {
        [curView resignFirstResponder];
    }
}


'개발 > App Developer' 카테고리의 다른 글

스텍(Stack), PUSH, POP  (0) 2010.08.31
계산기 형변환에 관해서 읽어볼것  (0) 2010.08.31
터치 관련  (0) 2010.08.31
개발자 등록없이 아이폰에 등록하기  (0) 2010.08.31
CGRect  (0) 2010.08.31