아이폰어플개발정보2010. 9. 11. 09:27
아이폰 어플 개발할때 pickerView 세팅하는 방법

pickerView의 디스플레이될 데이타항목 세팅시 나타낼것

#pragma mark -

#pragma mark UIPickerViewDataSource

//picker의 선택항목이 두개일때

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component

{

NSString *returnStr = @"";

// note: custom picker doesn't care about titles, it uses custom views

if (pickerView == myPickerView)

{

if (component == 0)

{

returnStr = [pickerViewArray objectAtIndex:row];

}

else

{

returnStr = [[NSNumber numberWithInt:row] stringValue];

}

}

return returnStr;

}

//각 분리된 항목별 디스플레이면적

- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component

{

CGFloat componentWidth = 0.0;

if (component == 0)

componentWidth = 240.0;// first column size is wider to hold names

else

componentWidth = 40.0;// second column is narrower to show numbers

return componentWidth;

}

//

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component

{

return40.0;

}

//갯수

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component

{

return [pickerViewArraycount];

}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView

{

return2;

}




출처 : http://blog.naver.com/PostList.nhn?blogId=philipousys¤tPage=11
Posted by 오늘마감

댓글을 달아 주세요