Sunday, December 11, 2011

adding Volume Control in Objective-C


The best thing about this small feature is easy implementation in any class. We just import MediaPlayer framework in header of our class (#import <MediaPlayer/MPVolumeView.h>) and add this code below in method we know that is appropriate for this feature (init method).
1
2
3
4
5
6
MPVolumeView *volumeView = [[[MPVolumeView alloc] initWithFrame:CGRectMake(0, 0, 200, 20)] autorelease];
 
volumeView.center = CGPointMake(150,370);
[volumeView sizeToFit];
 
[self.view addSubview:volumeView];

No comments:

Post a Comment