Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. + (void)preventSystemVolumePopup {
  2. // Prevent Audio-Change Popus
  3. MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(-2000., -2000., 0.f, 0.f)];
  4. NSArray *windows = [UIApplication sharedApplication].windows;
  5.  
  6. volumeView.alpha = 0.1f;
  7. volumeView.userInteractionEnabled = NO;
  8.  
  9. if (windows.count > 0) {
  10. [[windows objectAtIndex:0] addSubview:volumeView];
  11. }
  12. }
  13.  
  14. MPVolumeView *volView = [[MPVolumewView alloc] init];
  15. [self.view addSubview:volView];
  16. volView.hidden = YES;
  17.  
  18. - (void)viewDidLoad {
  19. // Add an MPVolumeView to my view
  20. self.volView = [[MPVolumewView alloc] init];
  21. [self.view addSubview:self.volView];
  22. self.volView.hidden = YES;
  23. }
  24.  
  25. - (void)someButtonTouched {
  26. // Show the MPVolumeView (and hopefully hide the system overlay)
  27. self.volView.hidden = NO;
  28. }
  29.  
  30. - (void)refreshVolumeView {
  31. [self.volView willMoveToSuperview:self];
  32. [self.volView didMoveToSuperview];
  33. }
  34.  
  35. - (void)viewDidLoad {
  36. // Add an MPVolumeView to my view
  37. self.volView = [[MPVolumewView alloc] init];
  38. [self.view addSubview:self.volView];
  39. self.volView.hidden = YES;
  40. }
  41.  
  42. - (void)someButtonTouched {
  43. // Show the MPVolumeView (and hopefully hide the system overlay)
  44. self.volView.hidden = NO;
  45. [self refreshVolumeView]; // <<< This line was added
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement