티스토리 뷰
1. textField클릭시 처리
:view를 하나 만들어서 올리는거처럼 보이게 한다.
- (void)keyboardWillShow:(NSNotification *)notice
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = self.view.frame;
rect.origin.y -= 215;
rect.size.height += 215;
self.view.frame = rect;
[UIView commitAnimations];
}2. 리턴 버튼 클릭시 처리
:만들어진 view의 y좌표를 조절하여 내리는거처럼 보이게 한다.
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = self.view.frame;
rect.origin.y += 215;
rect.size.height -= 215;
self.view.frame = rect;
[UIView commitAnimations];
return YES;
}- (void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:self.view.window];
}
- (void)viewWillDisappear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
}'Object-C,Swift Tip' 카테고리의 다른 글
iOS 개발자 등록에 있어 국내카드로 결제시 인증 실패한 경우 (0) | 2011.09.01 |
---|---|
숫자만 골라내기 (0) | 2011.08.31 |
block 사용 (0) | 2011.08.31 |
URL이미지 저장 (0) | 2011.07.23 |
ASIHTTPRequest (0) | 2011.05.13 |