0
프로그래밍 방식으로 UIPickerView
을 구현하려고합니다. 델리게이트와 데이터 소스를 구현했습니다. 처음으로 UIPickerView
으로 이동하면 모든 것이 잘 동작합니다. View
을 종료하고 나중에 다시 돌아 오면 UIPickerView
이 정상적으로 보입니다. 하지만 다른 항목을 선택하려고하면 충돌이 발생합니다. 디버깅 할 때 데이터 배열이 비어 있음을 알았습니다. 그러나 나는 왜 그런지 모른다.탐색 후 UIPickerView가 손실되었습니다.
DropDownController *objPickerView = [[DropDownController alloc] init];
objPickerView.userInfo = userInfo;
[objPickerView setDataSourceForPickerView:[dropDownItem valueForKey:@"dropDownEntries"] withPreselectedItem:preSelectedItem];
[dropDownContainer addSubview:objPickerView.picker];
피커이 컨트롤러에 있습니다 :
@interface DropDownController : UIViewController <FormElement, UIPickerViewDelegate, UIPickerViewDataSource>
{
NSArray *dropDownData;
UIPickerView *picker;
UIElement *userInfo;
}
@property (strong, nonatomic) NSArray *dropDownData;
@property (strong, nonatomic) IBOutlet UIPickerView *picker;
@property (nonatomic, retain) UIElement *userInfo;
-(void)setDataSourceForPickerView:(NSArray *)dataDictionary withPreselectedItem:(NSString*) preSelectedItem;
@end
여기
내가 설정 한 위임 및 데이터 소스 : 클래스에서
은 내가 UIPickerView
초기화하기
-(void)setDataSourceForPickerView:(NSMutableArray *)dataDictionary withPreselectedItem:(NSString*) preSelectedItem{
picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 300, 162)];
picker.delegate = self;
picker.dataSource = self;
picker.showsSelectionIndicator = YES;
dropDownData = dataDictionary;
}
복귀 후 보기 dropDownData
은 비어 있습니다.