ios - 选择视频时可以更改 `UIImagePickerController`的标题吗?

标签 ios objective-c uiimagepickercontroller video-capture photo-gallery

我打开了照片库来选择视频。这是我的代码:

- (void)selectMediaFrom:(UIImagePickerControllerSourceType)sourceType {
     UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.sourceType = sourceType;
    imagePicker.delegate = self;
    //imagePicker.allowsEditing = YES;

    if (selectedMediaType == MediaVideos) {
        imagePicker.mediaTypes = @[(NSString *)kUTTypeMovie, (NSString *)kUTTypeVideo];
        if (sourceType == UIImagePickerControllerSourceTypeCamera) {
            imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
        }
    }
    else if (selectedMediaType == MediaPhotos) {
        imagePicker.mediaTypes = @[(NSString *)kUTTypeImage];
        if (sourceType == UIImagePickerControllerSourceTypeCamera) {
            imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
        }
    }

    if (IS_IPHONE) {
        [self presentViewController:imagePicker animated:TRUE completion:nil];
    }
    else {
        dispatch_async(dispatch_get_main_queue(), ^{

            [self setModalPresentationStyle:UIModalPresentationFormSheet];
            [self presentViewController:imagePicker animated:TRUE completion:nil];
        });
    }
}

并且它总是将UIImagePickerController的标题显示为照片,请参阅我附加的屏幕截图。

imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary and imagePicker.mediaTypes = @[(NSString *)kUTTypeMovie, (NSString *)kUTTypeVideo]

但是,我已经打开iPhone默认照片应用并检查,显示视频文件夹:见下文

Default Photos App

那为什么不显示视频标题?我们可以改变它吗?

最佳答案

是的,您可以更改所需的导航标题。

添加UINavigationControllerDelegate的委托(delegate)

swift 3.0

func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool){
    viewController.navigationItem.title = "Kirit Modi"
}

objective-c

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
    [viewController.navigationItem setTitle:@"Kirit Modi"];
}

查看输出:

enter image description here

关于ios - 选择视频时可以更改 `UIImagePickerController`的标题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46599848/

相关文章:

ios - 如何在按钮上设置图像

iOS 全屏动画与 opengl es

ios - 登录时从 Twitter 获取数据

ios - 使用 weak self 避免在闭包中保留循环

objective-c - 尝试制作自定义 TabBar。在 iPhone 3GS 中使用 viewController 转换会崩溃(但在 iPhone 4 中不会)

ios - UIBarButtonSystemItem 信息和统计

iphone - UIImagePickerController AVAudioPlayer

ios - Xcode 中的不可见断点

iphone - 核心数据保存成功,但数据库中没有数据

ios - 裁剪 UIImage 的部分以获得新的纵横比并缩小尺寸