Objective c 如何定位MPVolumeView?

Objective c 如何定位MPVolumeView?,objective-c,xcode,Objective C,Xcode,我无法定位MPVolumeView。在我的viewController的viewDidLoad方法中,我有以下代码: [super viewDidLoad]; MPVolumeView *myVolumeView = [[MPVolumeView alloc] initWithFrame: self.volumeView.bounds]; [self.volumeView addSubview: myVolumeView]; 在故事板中,我添加了volumeView,并将其连接到控制器。 我包

我无法定位MPVolumeView。在我的viewController的viewDidLoad方法中,我有以下代码:

[super viewDidLoad];
MPVolumeView *myVolumeView = [[MPVolumeView alloc] initWithFrame: self.volumeView.bounds];
[self.volumeView addSubview: myVolumeView];
在故事板中,我添加了volumeView,并将其连接到控制器。 我包括两个截图:一个是故事板,另一个是在手机上运行时视图的外观

如何在volumeView中定位MPVolumeView?
最简单的方法是在Interface Builder中而不是在代码中创建
MPVolumeView
。您可以通过将自定义的
UIView
拖动到XIB中,根据需要对其进行配置,然后将其类更改为
MPVolumeView

来完成此操作,但我仍然想知道为什么我的代码不起作用…:-)
self.volumeView
是红色框吗?我怀疑你的插座可能连接不正确。