영화 및 액터 배열이 포함 된 모델 객체가 있습니다. 동일한 ViewController에서 2 개의 선택기 (영화와 함께 한 선택기와 다른 선택기)를 채우려고합니다. 나는 그것이 어떻게 작동 하는지를 아직도 배우고 있기 때문에 제발 도와주세요.동일한보기 컨트롤러에서 2 개의 다른 선택기를 사용하여 2 개의 다른 배열을 표시하는 방법은 무엇입니까?
감사합니다. 내 코드는 다음과 같습니다
...
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.model = [[MovieModel alloc] init];
for(int i = 0; i < self.model.count; i++){
NSString *movies = [self.model movieForIndex:i];
NSLog(@" Movie = %@", movies);
}
for(int i = 0; i < self.model.count; i++){
NSString *actors = [self.model actorForIndex:i];
NSLog(@" Actor = %@", actors);
}
}
는 // 이것은 내가 문제가있어 장소입니다. 감사!!!
#pragma mark - Picker View Delegate
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (component == 0){
return [self.model movieForIndex: row];
}
else if (component == 1){
return [self.model actorForIndex: row];
}
else
return nil;
}
#pragma mark - Picker View Data Source
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return self.model.count;
}
@end
당신이 1 선택기를 원하십니까 구성 요소 (열) 또는 각 구성 요소가 두 개인 피커? – TreeTree
"이슈"에는 어떤 종류의 이슈가 있습니까? Model 클래스는 어떤 모습입니까? –