2012-04-02 59 views
5

Tôi có một UIActionSheet cho iPad trong đó có ba lựa chọn:UIStatusBarStyleBlackTranslucent không có sẵn trên thiết bị này

  1. Hủy
  2. Máy ảnh
  3. Thư viện ảnh

Khi tôi chạm vào "Thư viện ảnh "tùy chọn Tôi gặp sự cố và thông báo

UIStatusBarStyleBlackTranslucent không khả dụng trên thiết bị này.

Tôi đã đọc this post, nhưng không tìm ra.

Ai đó có thể giúp tôi không?

Cập nhật:

-(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]; 
} 
} 

tôi nhận vụ tai nạn ở dòng cuối cùng tức là [self presentModalViewController:imgController animated:YES];

+1

Đọc bài đăng nào? – BoltClock

+0

Xin lỗi. Bỏ lỡ nó. Bây giờ đã chỉnh sửa. Hãy kiểm tra. – Nitish

Trả lời

0

Hãy thử gỡ bỏ cài đặt thanh trạng thái của bạn từ các tập tin plist tất cả với nhau và thêm dòng sau vào bạn AppDelegate'sapplicationDidFinishLaunchingWithOptions:

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

CẬP NHẬT:

Hãy thử điều này

-(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

Không, nó không giúp được gì. Vui lòng xem câu hỏi đã chỉnh sửa của tôi. – Nitish

+0

Kiểm tra cập nhật, đây là điều duy nhất tôi ngay lập tức thấy rằng tôi sẽ làm khác đi. –

+0

Điều gì khác biệt? – Nitish

0

Một chút muộn nhưng là UIViewController whats gọi presentModalViewController:animated: một đứa trẻ của một UIPopoverController? Nếu vậy, đó là những gì gây ra điều này. Thử gọi nó từ popovers parentViewController

1

thử mã dưới đây tác phẩm của nó đối với tôi hoàn hảo

- (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

Đối với iPad nó được khuyến cáo rằng bạn nên sử dụng popover trình bày MediaBrowser (camera/photoLibrary):

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

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

Bạn cũng có thể thiết lập các quan điểm nội dung cho popover:

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

cũng như bạn đã chỉ ra với the post mà bạn đã đọc, giải pháp đơn giản sẽ thêm một hàng vào danh sách với khóa-giá trị sau

UIStatusBarStyle ~ ipad | Chuỗi | UIStatusBarStyleBlackOpaque

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

Đây là một trong những giải pháp nếu bạn không muốn làm quá nhiều "công việc bẩn thỉu" trên mã ở đó, chỉ để lại nó vào plist để có được công việc làm.

Nhưng nếu bạn không ngại viết mã, giải pháp được đưa ra bởi VSN sẽ thực hiện tương tự như đề xuất của tôi.