Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "ViewController.h"
- @interface ViewController ()
- @end
- @implementation ViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- UIDevice *device = [UIDevice currentDevice];
- device.proximityMonitoringEnabled = YES;
- // Proximity Sensor Notification
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityChanged:) name:@"UIDeviceProximityStateDidChangeNotification" object:device];
- }
- - (void)proximityChanged:(NSNotification *)notification {
- UIDevice *device = [notification object];
- if (device.proximityState == 1) {
- // [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
- NSLog(@"Vao roi");
- } else {
- NSLog(@"Cung Vao roi");
- // [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment