liebus
알림 창 - UIAlertView 만들기 본문
UIAlertView 와 UIActionSheet
UIAlertView는 팝업창 이라 생각 하면 되고
UIActionSheet는 모달뷰 형식의 선택 메뉴 정도라 생각 하면 될듣
사용하는 방법은 완전 비슷 한다.
UIAlertViewDelegate 또는 UIActionSheetDelegate 를 Protocol로 선언한다.
UIAlertView *av = [[UIAlertView alloc]
initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[av setTitle:@"Hidden Memo"];
[av show];
[av release];
물론 위의 그림은 UIAlertView에 UITextField를 붙여 넣은 그림 이고 위의 코드 같이 했을 경우에는
TextField가 없는 Alert창이 보인다.
버튼 클릭 이벤트는
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:
(NSInteger )buttonIndex { }
에서 처리
UIActionSheet *voiceMenu = [[UIActionSheet alloc] initWithTitle:nil
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"녹음 하기"
otherButtonTitles:@"파일 선택", nil];
[voiceMenu showInView:self.view];
[voiceMenu release];
버튼을 클릭했을 때 전달된 이벤트는
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { }
에서 처리 한다.
- 추가 UIAlertView에 UITextFile 붙이기
//AlertView를 생성하고
delegate:self cancelButtonTitle:ALERT_CANCEL
otherButtonTitles:ALERT_OK, nil];
//TextFile를 생성하고 - 생성하면서 위치와 크기를 잡아 준다.
//AlertView안에 위치를 고려
UITextField *alertViewTextField = [[UITextField alloc]
initWithFrame:CGRectMake(12.0f, 70.0f, 260.0f, 26.0f)];
//TextFile를 의 스타일을 잡고
alertViewTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
alertViewTextField.keyboardAppearance = UIKeyboardAppearanceAlert;
alertViewTextField.autocapitalizationType =
UITextAutocapitalizationTypeWords;
alertViewTextField.autocorrectionType = UITextAutocorrectionTypeNo;
alertViewTextField.contentVerticalAlignment =UIControlContentVerticalAlignmentCenter;
[avRecored setTitle:@"Game over"];
//AlertView의 위치를 잡아주고
[avRecored setTransform:CGAffineTransformMakeTranslation(0.0, 0.0)];
//일케 해도 되더라
//CGRect bounds = av.bounds;
//alertViewTextField.center = CGPointMake(bounds.size.width / 2.0f,
bounds.size.height / 2.0f - 10.0f);
[avRecored addSubview:alertViewTextField];
[avRecored show];
[avRecored release];
//키보드를 불러온다.
출처 - 나
'예전꺼(2014년이전꺼) > iOS' 카테고리의 다른 글
Documents 에서 이미지 읽기 (0) | 2011.03.31 |
---|---|
UIView 터치이벤트 (0) | 2011.03.28 |
NSDate를 NSString으로 또는 반대 경우 (0) | 2011.02.26 |
상위 view 의 Controller를 사용하고자 할때 (0) | 2011.02.22 |
뷰 간의 이동 (3) | 2011.02.21 |