Trying to add MPVolumeView programmtically in app by using the following code

 MPVolumeView *_volumeView = [ [MPVolumeView alloc] init];
[_volumeView setShowsVolumeSlider:YES];
[_volumeView setShowsRouteButton:YES];
[_volumeView sizeToFit];
[view addSubview:_volumeView];

but getting so many Semantic issue that use of undeclared identifier MPVolumeView and Invalid operands to binary expression

@property (nonatomic, strong) MPVolumeView *volumeView;

Getting message in red for the above statement that unknown type MPVolumeView and plus property with retain or strong must be of object type.

 @synthesize volumeView = _volumeView;

Is this the right way to add MPVolumeView programmatically in app.

Thanks for help.

有帮助吗?

解决方案

MPVolumeView is part of the MediaPlayer framework. Did you include this in your application and did you #import <MediaPlayer/MediaPlayer.h> in your .m or .h file?

Also, if you declared a property, you should create a new local variable _volumeView. Replace the first line with this:

_volumeView = [ [MPVolumeView alloc] init];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top