Your SlideShare is downloading. ×
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона

1,433
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,433
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Разработка под iOS Лекция 4Возможности телефона Глеб Тарасов
  • 2. Интернет
  • 3. Reachabilityhttp://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
  • 4. Есть ли интернет?Reachability *r = [Reachability reachabilityForInternetConnection];if (r.status != NotReachable){ NSLog(@"Есть интернет");}
  • 5. WiFi или 3GReachability *r = [Reachability reachabilityForLocalWiFi];if (r.status != NotReachable){ NSLog(@"Есть wifi");}
  • 6. Акселерометр, гироскоп
  • 7. ОриентацияUIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;if (UIInterfaceOrientationIsPortrait(orientation)) NSLog(@"portrait");else NSLog(@"landscape");typedef enum { UIInterfaceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight} UIInterfaceOrientation;
  • 8. Акселерометр@interface MyViewController : UIViewController<UIAccelerometerDelegate>- (void)viewDidLoad{ [super viewDidLoad]; [[UIAccelerometer sharedAccelerometer] setDelegate:self]; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:0.01];}#pragma mark - UIAccelerometerDelegate- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{ NSLog(@"%g %g %g", acceleration.x, acceleration.y, acceleration.z);}
  • 9. 1.0 по осиускорение +1.0g вдоль этой осиКогда телефон лежит на столе: x=0 y=0 z = -1
  • 10. Фильтр нижних частотhttp://ru.wikipedia.org/wiki/Фильтр_нижних_частотhttp://developer.apple.com/library/ios/#samplecode/AccelerometerGraph/Introduction/Intro.html
  • 11. Гироскоп
  • 12. - (void)viewDidLoad{ [super viewDidLoad];) motionManager = [[CMMotionManager alloc] init]; timer = [NSTimer scheduledTimerWithTimeInterval:1/30.0 target:self selector:@selector(doGyroUpdate) userInfo:nil repeats:YES];}- (void)doGyroUpdate{ CMRotationRate rate = motionManager.gyroData.rotationRate;) NSLog(@"%g %g %g", rate.x, rate.y, rate.z);}
  • 13. Геолокация
  • 14. Координаты@interface Locator : NSObject<CLLocationManagerDelegate>manager = [[CLLocationManager alloc] init];manager.delegate = self;manager.desiredAccuracy = kCLLocationAccuracyHundredMeters;[manager startUpdatingLocation];- (void)locationManager:(CLLocationManager *)m) didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ CLLocationCoordinate2D coord = newLocation.coordinate; NSLog(@"%g %g", coord.latitude, coord.longitude);}
  • 15. КомпасlocationManager = [[CLLocationManager alloc] init];locationManager.desiredAccuracy = kCLLocationAccuracyBest;[locationManager setDelegate:self];[locationManager startUpdatingHeading];- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading{ NSLog(@"%g", newHeading.magneticHeading);}
  • 16. Работа с микрофоном
  • 17. SpeakHerehttp://developer.apple.com/library/ios/#samplecode/SpeakHere/Introduction/Intro.html
  • 18. Воспроизведение аудио
  • 19. AVAudioPlayerNSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"mp3"];NSURL *url = [NSURL fileURLWithPath:path];AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];[player play];
  • 20. - (void) viewDidAppear:(BOOL)animated{ [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self becomeFirstResponder];}- (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent{ if (receivedEvent.type == UIEventTypeRemoteControl) { switch (receivedEvent.subtype) { case UIEventSubtypeRemoteControlTogglePlayPause: [self playPause]; break; case UIEventSubtypeRemoteControlPreviousTrack: [self rewind]; break; case UIEventSubtypeRemoteControlNextTrack: [self forward]; break; default: break; } }}
  • 21. Воспроизведение видео
  • 22. MPMoviePlayerViewControllerNSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"mp4"];NSURL *url = [NSURL fileURLWithPath:path];MPMoviePlayerViewController *c = [[MPMoviePlayerViewController alloc] initWithContentURL:url];[self presentModalViewController:c animated:YES];
  • 23. Фото и видео
  • 24. Видео с камерыUIImagePickerController *c = [[UIImagePickerController alloc] init];c.delegate = self;c.sourceType = UIImagePickerControllerSourceTypeCamera;c.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];[self presentModalViewController:c animated:YES];- (void)imagePickerController:(UIImagePickerController *)pickerdidFinishPickingMediaWithInfo:(NSDictionary *)info{ UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; [picker dismissModalViewControllerAnimated:YES];}
  • 25. Фото из альбомов UIImagePickerController *c = [[UIImagePickerController alloc] init]; c.delegate = self; c.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;- (void)imagePickerController:(UIImagePickerController *)pickerdidFinishPickingMediaWithInfo:(NSDictionary *)info{ NSURL *url = [info objectForKey:UIImagePickerControllerMediaURL];}
  • 26. Что писать?
  • 27. Top 25 paid Top 25 free19 игр 1 мессенджер 17 игр 1 мессенджер2 книги 3 утилиты 3 развлекательных программы 1 соц. сеть 3 утилиты
  • 28. Education
  • 29. Entertainment
  • 30. Photo & Video
  • 31. Navigation
  • 32. Games
  • 33. Варианты приложений
  • 34. ЗадачиРешение задач (вроде diofant.ru) Задания ЕГЭ
  • 35. Пониматика Детские развивающие приложения Найди спрятанные объектыСоедини линии по числам и получи объект Комиксы Раскраска
  • 36. СервисыТВ-программа