我有开放的照片库来选择视频。这是我的代码:
- (void)selectMediaFromUIImagePickerControllerSourceType)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 的标题显示为 Photos,请参见我附上的截图。
但是,我打开 iPhone 默认 照片应用程序 并检查,显示视频文件夹:见下文
那为什么它不显示 Videos 标题?我们可以改变它吗?
Best Answer-推荐答案 strong>
是的,您可以更改所需的导航标题。
添加UINavigationControllerDelegate 的委托(delegate)
Swift 3.0
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool){
viewController.navigationItem.title = "Kirit Modi"
}
Objective-C
- (void)navigationControllerUINavigationController *)navigationController willShowViewControllerUIViewController *)viewController animatedBOOL)animated{
[viewController.navigationItem setTitle"Kirit Modi"];
}
查看输出:
关于ios - 选择视频时是否可以更改 `UIImagePickerController` 的标题?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/46599848/
|