2013-08-07 2 views
0

나는이 작업 시트를 작성하는 방법과 uipicker 있습니다 DONE 읽기 나타납니다UIActionSheet에서 프로그래밍 방식으로 완료 단추를 수정하는 방법?

-(void)presentNewPicker{ 
    self.aac = [[UIActionSheet alloc] initWithTitle:@"What City?" 
                delegate:self 
              cancelButtonTitle:nil 
             destructiveButtonTitle:nil 
              otherButtonTitles:@"OK", 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: @"Phoenix", @"Tahoe", @"Nevada", @"Lime", @"Florida", 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(dismissActionSheet:)]; 

    [barItems addObject:doneBtn]; 

    [pickerDateToolbar setItems:barItems animated:YES]; 

    [self.aac addSubview:pickerDateToolbar]; 


    [self.aac addSubview:self.pickrView]; 
    [self.aac showInView:self.view]; 
    [self.aac setBounds:CGRectMake(0,0,320, 464)]; 
} 

버튼을하지만, 준비를 읽고 수정하고 싶습니다. 어떻게해야합니까?

+0

이것은 'UIActionSheet'의 총 오용입니다. 'UIActionSheet'는 일련의 버튼을 보여주기 위해서만 사용됩니다. 그게 전부 야. 내가하고있는 일을하는 것이 iOS에 대한 향후 업데이트에서 중단 될 가능성이 있습니다. – rmaddy

+0

@rmaddy 글쎄, 실제로 그 코드를 얻었습니다. 동일한 뷰 내에서 UIPickerView를 표시하려면 무엇을 제안 하시겠습니까? – marciokoko

+0

피커 및 기타 버튼으로 나만의보기를 만듭니다. 그런 다음 자신 만의 애니메이션을 실행하여 뷰를 표시하거나 닫습니다. – rmaddy

답변

1

은 교체 :

UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissActionSheet:)]; 

로 :

UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"Ready" style: UIBarButtonItemStyleBordered target:self action:@selector(dismissActionSheet:)]; 

당신은 스타일 UIBarButtonItemStyleDone을 사용할 수 있습니다.

관련 문제