Transcript iPhone_2_1

iPhone Seminar Ⅱ (심화)
2010 . 05 . 10 . 금
정보통신연구소 유승구 연구원
Rev. No. 1.2
Last modified: 2010/05/07
2015-04-13
NOVAPEX Mobile Co., LTD
Confidential
Agenda
◈ iPhone : application develop
1. iPhone UIView controll
1. UIControl
2. 데이터 표시
3. 알림 뷰
4. 뷰의 전환
2. iPhone View Controller
1. Navigation Controller
2. Tab Bar Controller
참고 링크
2
Confidential
1-1. UIControl
◈ UIControl 라이브러리
• Interface Builder 에서 라이브러리를 드래그 하는 것으로 추가가 가능
• 각 라이브러리의 속성을 변경하여 스타일을 프로그램에 맞게 변경 가능
• 사용자의 입력결과와 값 속성을 보여준다.
• UIView를 상속받음
3
Confidential
1-1. UIControl
◈ UIControl : UISlider
눈금이 이동하면서 값을 반환 하는 컨트롤
float value;
// 슬라이더 눈금 값
float minimumValue; // 슬라이더의 최소 값
float maximumValue; // 슬라이더의 최대 값
-(void)setValue:(float)value animated:(BOOL)anmated
-(IBAction)sliderValueChanged;
UISlider와 연결시켜 놓으면 값이 변경 될 때마다 이벤트가 SlidervalueChanged로 돌아온다.
4
Confidential
1-1. UIControl
◈ UIControl : UISwitch
둘 중 한가지의 선택을 할 때 사용되는 컨트롤러
BOOL on
-(void)setOn:(BOOL)on animated:(BOOL)animtaed
스위치의 On/Off를 On이라는Bool 타입 변수로 설정 가능
-(IBAction)soundChanged{
if(soundSwitch.on == TRUE)
{….
}
5
Confidential
1-1. UIControl
◈ UIControl : UISegmented
사용자가 두개 이상의 선택 중 하나를 고르거나 여러 개의
행동 중 하나를 선택하고자 할 때 많이 사용된다.
NSUInteger numberOfSegments : 세그먼트 개수 저장
UISegmentedControlStyle segmentedControlStyle : 스타일 설정
NSInteger selectedSegmentIndex : 현재 선택된 세그먼트의 인덱스
setImage:(UIImage *)image forSegmentAtIndex:(NSUInteger)segment
특정 세그먼트에 이미지 지정
setTitle:(NSString*)title forSegmentAtIndex:(NSUInteger)segment
특정 세그먼트의 제목을 지정
6
Confidential
1-2. Data 표시
◈ Data Views 라이브러리
• Data 를 효과적으로 보여주기 위한 컨트롤
7
Confidential
1-2. Data 표시
◈ Data View : UILabel
// Header file
@interface MySettingViewController : UIViewController {
IBOutlet UILabel *TitleLabel;
}
@end
// Source file
- (void)viewDidLoad {
[super viewDidLoad];
@property (nonatomic, copy) NSSTring *text : 레이블 표시될 내용
TitleLabel = @"Test Apps!";
}
※ Label 주요 설정 값 : UIFont, UIColor, UITextAlignment, UILineBreakMode, adjustsFontSizeToFitWidth
8
Confidential
1-2. Data 표시
◈ Data View : UIImageView
// Source file
- (void)viewDidLoad{
UIImage *backgroundImage = [UIImage imageNamed:@"backgournd.jpg"];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:backgroundImage];
backgroundImageView.frame = [[UIScreen mainScreen] bounds];
backgroundImageView.contentMode = UIViewContentModeScaleAspectFit;
backgroundImageView.alpha = 0.55;
[self.view addSubview:backgroundImageView];
[self.view sendSubviewToBack:backgroundImageView];
[backgroundImageView release];
}
9
Confidential
1-2. Data 표시
◈ Data View : Content Mode
Original image
Scale To Fill
ScaleAspectFit
ScaleAspectFill
비율 유지 안함
비율 유지
비율 유지
10
Confidential
1-3. 알림 뷰
◈ 사용자 알림 뷰
클래스의 쓰임상 특정한 상황을 사용자에게 알리는 데 이용되는 여러 가지 클래스를 말한다.
◈ UIAlertView
• 사용자에게 간단한 정보를 알리거나 특정 상황에 대해 경고를 하기 위한 알림 창의 용도
• 특정 상황에서 모달(Modal) 형태로 띄워지기 때문에 IB에서는 생성 할 수 없다.
• 코드로만 객체를 생성하고 동작이 가능
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"제목"
message:@"알림 메시지"
delegate:self cancelButtonTitle:@"예"
otherButtonTitles:@"아니오", nil];
[alertView show];
[alertView release];
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
11
Confidential
1-3. 알림 뷰
◈ UIActionSheet
사용자에게 알림 메시지를 보여주고 버튼을 통해 입력을 받는 형태
UIActionSheetStyle *actionSheetStyle = [[UIActionSheetStyle alloc] initWithTitle:@"제목"
message:@"알림 메시지"
delegate:self cancelButtonTitle:@"예"
otherButtonTitles:@"아니오", nil];
actionSheetStyle.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheetStyle showInView:self.view];
[actionSheetStyle release];
클릭시 불려지는 함수 프로토콜
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
12
Confidential
1-4. 뷰의 전환
◈ View의 위치 전환
키보드가 입력란을 덮어 보이지 않을 경우 -> 화면을 위로 키보드 크기만큼 올린다.
키보드 수행 종료 후 리턴키가 눌렸을 때 ->화면을 다시 내린다.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
CGRect rect = self.view.frame;
rect.origin.y -=100;
rect.size.height +=100;
self.view.frame = rect;
[UIView commitAnimations];
13
Confidential
2-1. Navigation Controller
◈ Navigation Controller
• 뷰 사이의 간단한 이동을 위해 사용
• Root View Controller를 이용해 관리하게 될 뷰 컨트롤러의 스택이 생성된다.
RootViewController *rootViewContrller;
NavigationController *navigationController;
rootViewController = [[RootViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithViewController:rootViewController];
[window addSubview:[navigationController view]];
14
Confidential
2-1. Navigation Controller
◈ Pushing/Popping View Controller
• pushViewController
• popViewControllerAnimated (직접 호출 하여 사용하지 않음)
• Navigation 스택에 새로운 아이템을 추가하거나 제거
AddedViewController *viewContoller = [[AddedViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
◈ Modal View Controller
• presentModalViewController:(UIViewController *)modalViewController animated:
• dismissModalViewControllerAnimated:
• 현재의 뷰를 유지한채 새로운 뷰를 추가하고자 할 때 사용
[self.navigationController presentModalViewController:navController animated:YES];
[self.navigationController dismissModalViewController:navController animated:YES];
15
Confidential
2-2. Tab Bar Controller
◈ Tab Bar Controller
• 뷰 컨트롤러의 배열(NSMutableArray 클래스 타입)을 가지고 있음
• 여러 개의 뷰 사이를 이동할 수 있게 해줌
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = myViewController;
[window addSubview:tabBarController.view];
16
Confidential
마무리
감사합니다.
17
Confidential