0

UIActionSheetUIPickerView이 포함될 때마다 내 iOS 앱이 멈추는 문제가 있습니다. 내가 UIActionSheet의 "완료"버튼을 누르기 전까지는 픽커 휠이 잘 스크롤되어 UI가 정지합니다. 그러나 XCode는 프로그램에 어떤 종류의 충돌도 등록하지 않으므로 혼란 스럽습니다.UICctionSheet의 UIPickerView : UI가 멈춤

이전에이 문제가 발생한 사람이 있습니까? 어떻게 해결할 수 있습니까?

+1

코드를 표시하십시오. –

답변

1

나는 결코 이런 종류의 문제에 직면하지 않는다. 나는이 문제가 당신의 문제를 해결할 수 있다고 생각한다. 같은 방식으로 PickerView를 사용했습니다.

UIActionSheet *actionSheet; 
NSString *pickerType; 

- (void)createActionSheet { 
    if (actionSheet == nil) { 
     // setup actionsheet to contain the UIPicker 
     actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select" 
                delegate:self 
             cancelButtonTitle:nil 
            destructiveButtonTitle:nil 
             otherButtonTitles:nil]; 

     UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; 
     pickerToolbar.barStyle = UIBarStyleBlackOpaque; 
     [pickerToolbar sizeToFit]; 

     NSMutableArray *barItems = [[NSMutableArray alloc] init]; 

     UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; 
     [barItems addObject:flexSpace]; 
     [flexSpace release]; 

     UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(pickerDone:)]; 
     [barItems addObject:doneBtn]; 
     [doneBtn release]; 

     [pickerToolbar setItems:barItems animated:YES]; 
     [barItems release]; 

     [actionSheet addSubview:pickerToolbar]; 
     [pickerToolbar release]; 

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

-(IBAction)BtnPressed:(id)sender 
{ 
    [self createActionSheet]; 
    pickerType = @"picker"; 
    select = NO; 
    UIPickerView *chPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 44.0, 0.0, 0.0)]; 
    chPicker.dataSource = self; 
    chPicker.delegate = self; 
    chPicker.showsSelectionIndicator = YES; 
    [actionSheet addSubview:chPicker]; 
    sessoTxt.text = [sessoArray objectAtIndex:0]; 
    [chPicker release]; 
} 


#pragma mark UIPickerViewDelegate Methods 

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { 
    return 1; 
} 

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component 
{ 
    int count; 
    if ([pickerType isEqualToString:@"picker"]) 
     count = [array count]; 
return count; 
} 

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

    if ([pickerType isEqualToString:@"picker"]) 
     string = [array objectAtIndex:row]; 

return string; 
} 
// Set the width of the component inside the picker 
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component    { 
    return 300; 
} 

// Item picked 
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 
    select = YES; 
    if ([pickerType isEqualToString:@"picker"]) 
    { 
     Txt.text = [array objectAtIndex:row]; 
    } 
} 

- (void)pickerDone:(id)sender 
{ 
    if(select == NO) 
    { 
     if ([pickerType isEqualToString:@"picker"]) 
     { 
      Txt.text = [array objectAtIndex:0]; 
     } 
} 
    [actionSheet dismissWithClickedButtonIndex:0 animated:YES]; 
    [actionSheet release]; 
    actionSheet = nil; 

} 

}