2013-10-01 60 views
0

嗨我的用戶界面選擇器不再適用於iOS7,它彈出但它是空白的。只發生在iOS7上。UIPicker和UIActionsheet不再工作iOS7

//picker 
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ 
animationsLabel.text = [optionsArray objectAtIndex:[picker selectedRowInComponent:0]]; 

if (pickerView==animationsPicker) { 
    animationsLabel.text = [optionsArray objectAtIndex:[animationsPicker selectedRowInComponent:0]]; 
} 

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

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ 
    return [optionsArray count]; 
} 

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ 
    return [optionsArray objectAtIndex:row]; 
    NSLog(@"title options array %lu",(unsigned long)optionsArray.count); 
} 

和動作:

-(IBAction)animationActionSheet:(id)sender { 

UIActionSheet *selectPopup = [[UIActionSheet alloc] initWithTitle:@"\n\n\n\n\n\n\n\n" 
                 delegate:nil 
               cancelButtonTitle:nil 
              destructiveButtonTitle:nil 
               otherButtonTitles:nil]; 

[selectPopup showInView:self.view]; 

optionsArray = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"6",@"5",@"7",@"8",@"9", nil]; 

// Create picker 
animationsPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(10, 160, 320, 100)]; 
animationsPicker.showsSelectionIndicator = YES; 
[self.view addSubview:animationsPicker]; 
animationsPicker.delegate = self; 
animationsPicker.dataSource = self; 
[selectPopup addSubview:animationsPicker]; 

// Animate picker opening 
[UIView beginAnimations:nil context:nil]; 
[selectPopup setBounds:CGRectMake(0, 0, 320, 485)]; 
[UIView commitAnimations]; 
} 

這是我到目前爲止已經試過。之前在操作表單中顯示選取器時沒有問題,但現在它是空白的。我想知道有沒有其他人遇到這個問題,或者你能看到任何錯誤?我將所有內容都印刷在選取器上。

回答

5

有人告訴我,在行動表中放置拾取器是非標準的。我從來沒有在iOS 6中做過這樣的問題,但在iOS 7中,我遇到了錯誤。我切換到UIView而不是我的採集器的動作表,它工作正常。我希望這有幫助。

+0

非常感謝。我希望不是這樣,但它應該很容易解決。我希望保持它一樣。再次感謝。 – DevC

+0

我也希望這樣做,但把它們放在UIViews而不是ActionSheets中並不壞。祝你好運! – user1509295

2

不建議在每個文檔的操作表中添加子視圖。

「子類注 UIActionSheet的目的不是要被繼承,也不應該添加視圖的層次。如果你需要更多的定製呈現片狀不是由UIActionSheet API提供的,你可以創建自己的,並以presentViewController模式呈現:animated:completion :.「

蘋果正在強化它們在Action Sheets中的用法......並且他們提高了這個在iOS 7中工作的賭注,這意味着你必須對它進行編碼。