Language/Objective-C

[UIViewScroll] view and scroll Down

아르비스 2011. 4. 22. 10:02

// 텍스트필드 포커스시 키보드 비활성화 기능 버튼 활성화 스크롤 이동

- (void)textFieldDidBeginEditing:(UITextField *)textField {

    NSInteger frameSizeHeight = 460 - 215;

if (textField.tag < 3) {

        CGPoint bottomOffset = CGPointMake(0, 0);

        [scrollView setContentOffset: bottomOffset animated: YES];

    }

    else {

        CGPoint bottomOffset = CGPointMake(0, 200);

        [scrollView setContentOffset: bottomOffset animated: YES];

    }

    

    scrollView.frame = CGRectMake(scrollView.frame.origin.x, scrollView.frame.origin.y

                                  scrollView.frame.size.width, frameSizeHeight);


}


-(void)textFieldDidEndEditing:(UITextField *)textField { //keyboard will hide

    NSInteger frameSizeHeight = 460;

    scrollView.frame = CGRectMake(scrollView.frame.origin.x, scrollView.frame.origin.y

                                  scrollView.frame.size.width, frameSizeHeight);

    

//    scrollView.frame = CGRectMake(scrollView.frame.origin.x, scrollView.frame.origin.y, 

//                                  scrollView.frame.size.width, scrollView.frame.size.height + 215 - 50); //resize

}


- (void)viewDidLoad

{

    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.

    [scrollView setContentSize:CGSizeMake(320, 460*1.5)];


}


UIScrollView와 delegate의 연결만 설정해 주면..
스크롤링 가능하다.
size 계산이 힘들어 그냥 좌표 fix함..^^;