gpt4 book ai didi

iphone - iOS - MPMediaPickerController - 更改 barStyle

转载 作者:行者123 更新时间:2023-11-28 20:43:42 25 4
gpt4 key购买 nike

我找遍了所有地方,但似乎找不到有效的解决方案...

我正在开发一个应用程序,它使用 MPMediaPickerController 并创建一个模态视图,允许用户选择要播放的歌曲。我的主视图有一个 blackOpaque barStyle,我希望 Picker 具有相同的样式,但我似乎无法以任何方式更改 barStyle 或颜色。这是代码片段:

-(IBAction)showMediaBrowser:(id)sender  {
// Create a MediaPickerController object (alloc) and initialize with ONLY music type media
mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];

// CK - Set properties
mediaPicker.delegate = self;
mediaPicker.prompt = @"Choose your song:";
mediaPicker.navigationController.toolbar.barStyle = UIBarStyleBlackOpaque;

// CK - Present the model view and animate
[self presentModalViewController:mediaPicker animated:YES]; }

谢谢

最佳答案

在您尝试设置工具栏样式时,媒体选择器可能(很可能)没有导航工具栏。您是否检查过 mediaPicker.navigationController 是否有值?

我建议将媒体选择器 Controller 嵌入到您自己的 View 层次结构中(docs for MPMediaPickerController 说这是可能的),然后您将从自己的 View Controller 完全控制导航栏。

// create media picker controller
mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];

// set properties
mediaPicker.delegate = self;
mediaPicker.prompt = @"Choose your song:";

// get the media picker's view and set its frame
UIView *pickerView = mediaPicker.view;
pickerView.frame = myViewController.view.frame;

// add the media picker view to the view hierarchy
[myViewController.view addSubview:pickerView];

关于iphone - iOS - MPMediaPickerController - 更改 barStyle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7311864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com