簡體   English   中英

從UIImagePickerController攝像頭視圖中推送viewController

[英]Push a viewController from the UIImagePickerController camera view

我正在開發一個消息傳遞應用程序(類似於WhatsApp),用戶可以相互發送文本和圖像消息。

當用戶想要發送圖像時,他可以從相機膠卷中選擇一個,或者他可以用相機拍攝一個。

這就是我為兩種情況呈現UIImagePickerController的方式:

- (void)handleTakePhoto
{
    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];

    ipc.delegate = self;
    ipc.sourceType = UIImagePickerControllerSourceTypeCamera;

    [self presentModalViewController:ipc animated:YES];
    [ipc release];
}

- (void)handleChooseFromLibrary
{
    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
    ipc.delegate = self;
    ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    NSString *desired = (NSString *)kUTTypeImage;
    if ([[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary] containsObject:desired]) {
        ipc.mediaTypes = [NSArray arrayWithObject:desired];
    }

    [self presentModalViewController:ipc animated:YES];
    [ipc release];
}

在用戶選擇/拍照后,我正在推送一個SendImageViewController ,它以全屏顯示圖像,並有一個實際發送圖像的按鈕。

這是我推動它的方式:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];


    SendImageViewController *sivc = [[SendImageViewController alloc] initWithImage:image
                                                                          delegate:self];
    [picker pushViewController:sivc animated:YES];
    [sivc release];
}  

當我從相機膠卷推送SendImageViewController ,一切都很好。 問題是,當從相機拍攝圖像時,我無法推送我的SendImageViewController ,因為相機沒有導航欄(我試圖推動它但我的SendImageViewController視圖沒有很好地呈現)

我怎么處理這個?

*我不想解雇拾取器,然后推送SendImageViewController ,我希望SendImageViewController將被推到相機/相機膠卷的頂部,所以當我點擊后退按鈕時我會回到相機/相機膠卷視圖。

嘗試顯示導航欄,如下所示:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];

[picker setNavigationBarHidden:NO animated:YES];
[picker pushViewController:vc animated:YES];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM