나는 5 개 정적 세포와 테이블 뷰 컨트롤러가 하나는이 같은 UIPicker 호출작업 표에 제시된 UIPicker를 어떻게 해제합니까?
#pragma mark PickerView DataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [self.cityNames count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [self.cityNames objectAtIndex:row];
}
#pragma mark PickerView Delegate
-(void)presentNewPicker{
UIActionSheet *aac = [[UIActionSheet alloc] initWithTitle:@"For which city?"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
self.pickrView = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 44.0, 0.0, 0.0)];
self.pickrView.showsSelectionIndicator = YES;
self.pickrView.dataSource = self;
self.pickrView.delegate = self;
self.cityNames = [[NSArray alloc] initWithObjects: @"Akron", @"Indie", @"Springfield", @"Loria", @"Merida", nil];
UIToolbar *pickerDateToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerDateToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerDateToolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(pickerDoneClick)];
[barItems addObject:doneBtn];
[pickerDateToolbar setItems:barItems animated:YES];
[aac addSubview:pickerDateToolbar];
[aac addSubview:self.pickrView];
[aac showInView:self.view];
[aac setBounds:CGRectMake(0,0,320, 464)];
}
-(void) dismissActionSheet:(id)sender {
NSLog(@"dismissActionSheet");
UIActionSheet *actionSheet = (UIActionSheet *) ??? how do i get action sheet? :-);
[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
self.myCity.text = [self.cityNames objectAtIndex:row];
NSLog(@"city %@", self.myCity.text);
}
UIPicker이 제시하지만 난 완료 버튼을 클릭하면,하지만 어떻게 내가 지금 기각 할을? 또한, 도시는 null을 기록하고 있으며, 왜 그 도시와 함께 picker를 init'd했는지 확신 할 수 없으며, 한번 picker에 나타납니다.
음을, 그러나 나는 SO에이를 발견하고 작동 만들려고 노력했다. 하지만 나는 OK 버튼을 표시 할 수 없습니다 :'http://stackoverflow.com/questions/7464302/obj-c-showing-a-uipickerview-in-an-uiactionsheet-but-need-to-save-to- nsuserdef' – marciokoko
문제가 무엇인지 알 수 없습니다 - 표시하려는 버튼은 무엇입니까? – Kevin
제가 링크 된 게시물의 하나, 액션 시트의 otherButtonTitles입니다. – marciokoko