2012-04-02 3 views
5

У меня есть UIActionSheet для IPad, который имеет три варианта:UIStatusBarStyleBlackTranslucent не доступен на этом устройстве

  1. Отмена
  2. камеры
  3. библиотеки фотографий

Когда я касаюсь «Photo Library ». Я получаю сбой и сообщение

UIStatusBarStyleBlackTranslucent недоступен на этом устройстве.

Я прочитал this post, но не понял.

Может кто-нибудь мне помочь?

Update:

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 

    if (buttonIndex == 0) 
    { 

     imgController = [[UIImagePickerController alloc] init]; 
     imgController.allowsEditing = YES; 
     imgController.sourceType = UIImagePickerControllerSourceTypeCamera; 
     imgController.delegate=self; 
     [self presentModalViewController:imgController animated:YES]; 

    } 
    else if (buttonIndex == 1) 
    { 
     imgController = [[UIImagePickerController alloc] init]; 
     imgController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     imgController.delegate=self; 
     [self presentModalViewController:imgController animated:YES]; 
} 
} 

Я получаю сбой в последней строке т.е. [self presentModalViewController:imgController animated:YES];

+1

Прочитайте, что сообщение? – BoltClock

+0

Извините. Пропустил его. Теперь отредактирован. Пожалуйста, проверьте. – Nitish

ответ

0

Попробуйте удалить ваши настройки строки статуса из файла plist все вместе и добавить следующие строки в AppDelegate'sapplicationDidFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent]; 
} 

ОБНОВЛЕНИЕ:

Попробуйте

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
switch (buttonIndex) 
{ 
    case 0: 
    { 

     imgController = [[UIImagePickerController alloc] init]; 
     imgController.allowsEditing = YES; 
     imgController.sourceType = UIImagePickerControllerSourceTypeCamera; 
     imgController.delegate=self; 
     [self presentModalViewController:imgController animated:YES]; 

    } 
    case 1: 
    { 
     imgController = [[UIImagePickerController alloc] init]; 
     imgController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     imgController.delegate=self; 
     [self presentModalViewController:imgController animated:YES]; 
    } 
} 
} 
+0

Нет, это не помогло. См. Мой отредактированный вопрос. – Nitish

+0

Проверьте обновление, это единственное, что я сразу вижу, что я сделал бы по-другому. –

+0

В чем разница? – Nitish

0

Немного поздно, но в UIViewController, Что называя presentModalViewController:animated: ребенок из UIPopoverController? Если да, то что вызывает это. Попробуйте вызвать его из Popovers parentViewController

1

Попробуйте ниже код его работы для меня идеальный

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex: (NSInteger)buttonIndex 
{ 
if(buttonIndex==0) 
    { 
    [self takePhoto]; 

    } 
else if(buttonIndex==1) 
    { 
    [self choosePhoto]; 
    } 
} 


-(void)takePhoto 
{ 
UIDevice *device = [UIDevice currentDevice]; 

NSString *currDevice = [device model]; 

NSLog(@"device is %@",currDevice); 

    if(![currDevice isEqualToString:@"iPhone Simulator"]) 
     { 
     [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; 
    UIImagePickerController *imgPickerCon = [[UIImagePickerController alloc] init]; 
    imgPickerCon.sourceType = UIImagePickerControllerSourceTypeCamera; 
    imgPickerCon.delegate = self; 
    [self presentModalViewController:imgPickerCon animated:YES]; 
    [imgPickerCon release]; 
    imgPickerCon = nil; 
    } 
    else{ 
    UIAlertView *alrt=[[UIAlertView alloc] initWithTitle:@"Message" message:@"Camera Will Not Open in Simulator" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [alrt show]; 
    [alrt release]; 
} 
} 

-(void)choosePhoto 
{ 

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; 
UIImagePickerController *imgPickerCon = [[UIImagePickerController alloc] init];  
imgPickerCon.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
imgPickerCon.delegate = self; 
[self presentModalViewController:imgPickerCon animated:YES];   
[imgPickerCon release]; 
imgPickerCon = nil; 
    } 


    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{ 
[picker dismissModalViewControllerAnimated:YES]; 
} 

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)myimage editingInfo:(NSDictionary *)editingInfo 
    { 


[picker dismissModalViewControllerAnimated:YES]; 
image=myimage; 

imgView.image=myimage; 

    } 
10

для IPad рекомендуется, что вы должны использовать поповер представить MediaBrowser (камера/PhotoLibrary):

UIImagePickerController *ipc = [[UIImagePickerController alloc] init]; 

UIPopoverController *popOverController = [[UIPopoverController alloc] initWithContentViewController:ipc]; 
popOverController.delegate = self; 

Вы также можете установить вид контента для: пирог

ipc.delegate = self; 
ipc.editing = NO;  
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
ipc.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:ipc.sourceType]; 

[popOverController presentPopoverFromRect:btnGallery.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
0

Подобно тому, как вы указали с the post, что вы прочли, простым решением будет добавление строки в plist со следующим значением ключа

UIStatusBarStyle ~ ipad | Строка | UIStatusBarStyleBlackOpaque

(3rd row in the picture here, sorry cause I can't post image yet now)

Это один из раствора, если вы не хотите, чтобы сделать слишком много «грязную работу» на коды там, просто оставить его в PLIST, чтобы получить работу.

Но если вы не против писать коды, решение, данное VSN, будет делать то же, что и мое предложение.

Смежные вопросы