Contenu connexe
Similaire à Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
Similaire à Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона (20)
Plus de Глеб Тарасов (20)
Курсы по мобильной разработке под iOS. 4 лекция. Возможности телефона
- 5. WiFi или 3G
Reachability *r = [Reachability reachabilityForLocalWiFi];
if (r.status != NotReachable)
{
NSLog(@"Есть wifi");
}
- 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);
}
- 10. Фильтр нижних
частот
http://ru.wikipedia.org/wiki/Фильтр_нижних_частот
http://developer.apple.com/library/ios/#samplecode/
AccelerometerGraph/Introduction/Intro.html
- 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);
}
- 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);
}
- 19. AVAudioPlayer
NSString *path = [[NSBundle mainBundle] pathForResource:@"file"
ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:path];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url
error:nil];
[player play];
- 21. - (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;
}
}
}
- 23. MPMoviePlayerViewController
NSString *path = [[NSBundle mainBundle] pathForResource:@"file"
ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
MPMoviePlayerViewController *c
= [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentModalViewController:c animated:YES];
- 25. Видео с камеры
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 *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissModalViewControllerAnimated:YES];
}
- 27. Фото из альбомов
UIImagePickerController *c = [[UIImagePickerController alloc] init];
c.delegate = self;
c.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL *url = [info objectForKey:UIImagePickerControllerMediaURL];
}
- 30. Top 25 paid Top 25 free
19 игр 1 мессенджер 17 игр 1 мессенджер
2 книги 3 утилиты 3 развлекательных
программы
1 соц. сеть 3 утилиты
- 50. Пониматика
Детские развивающие приложения
Найди спрятанные объекты
Соедини линии по числам и получи объект
Комиксы
Раскраска