- iOS. 5 .

  • Published on
    29-Nov-2014

  • View
    2.759

  • Download
    4

DESCRIPTION

 

Transcript

  • 1. iOS 5
  • 2.
  • 3.
  • 4. Reachabilityhttp://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
  • 5. ?Reachability *r = [Reachability reachabilityForInternetConnection];if (r.status != NotReachable){ NSLog(@" ");}
  • 6. WiFi 3GReachability *r = [Reachability reachabilityForLocalWiFi];if (r.status != NotReachable){ NSLog(@" wifi");}
  • 7. ,
  • 8. UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;if (UIInterfaceOrientationIsPortrait(orientation)) NSLog(@"portrait");else NSLog(@"landscape");typedef enum { UIInterfaceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight} UIInterfaceOrientation;
  • 9. @interface MyViewController : UIViewController- (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. 1.0 +1.0g : x=0 y=0 z = -1
  • 11. http://ru.wikipedia.org/wiki/__http://developer.apple.com/library/ios/#samplecode/AccelerometerGraph/Introduction/Intro.html
  • 12.
  • 13. - (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.
  • 15. @interface Locator : NSObjectmanager = [[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);} : 55.747598, 37.626801
  • 16. locationManager = [[CLLocationManager alloc] init];locationManager.desiredAccuracy = kCLLocationAccuracyBest;[locationManager setDelegate:self];[locationManager startUpdatingHeading];- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading{ NSLog(@"%g", newHeading.magneticHeading);} 0 - , 90 - , 180 - , 270 -
  • 17.
  • 18. SpeakHerehttp://developer.apple.com/library/ios/#samplecode/SpeakHere/Introduction/Intro.html
  • 19.
  • 20. AVAudioPlayerNSString *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; } }}
  • 22.
  • 23. MPMoviePlayerViewControllerNSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"mp4"];NSURL *url = [NSURL fileURLWithPath:path];MPMoviePlayerViewController *c = [[MPMoviePlayerViewController alloc] initWithContentURL:url];[self presentModalViewController:c animated:YES];
  • 24.
  • 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 *)pickerdidFinishPickingMediaWithInfo:(NSDictionary *)info{ UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; [picker dismissModalViewControllerAnimated:YES];}
  • 26. / UIImagePickerController *c = [[UIImagePickerController alloc] init]; c.delegate = self; c.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;- (void)imagePickerController:(UIImagePickerController *)pickerdidFinishPickingMediaWithInfo:(NSDictionary *)info{ NSURL *url = [info objectForKey:UIImagePickerControllerMediaURL];}
  • 27. iPad
  • 28. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){ self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];}else{ self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];}
  • 29. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){ self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];}else{ self.viewController = [[ViewController_iPad alloc] initWithNibName:@"ViewController_iPad" bundle:nil];}
  • 30. @implementation UIViewController (Utils)+ (id)fromNib{ NSString *nibName = NSStringFromClass(self); return [self fromNib:nibName];}+ (id)fromNib:(NSString *)nibName{ return [[self alloc] initWithNibName:nibNamebundle:nil];}@end
  • 31. SplitViewController
  • 32. itunesconnect.apple.com + + InApp Purchases itunesconnect.apple.com +
  • 33. InApp Purchases StoreKit http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/Introduction/Introduction.html MKStoreKit https://github.com/MugunthKumar/MKStoreKit[[MKStoreManager sharedManager] buyFeature:self.appleId onComplete:^(NSString *featureId, NSData *receiptData) { // ... } onCancelled:^{ // ... }];
  • 34.
  • 35.
  • 36. XCode
  • 37. Debugger
  • 38. Instruments
  • 39. Apple~ 2-3 ~ 1 - AppStore (., QIWI) http://faxzero.com/
  • 40. iOS Dev Center (http://developer.apple.com)
  • 41. iTunes Connect (http://itunesconnect.apple.com)
  • 42. App Annie (http://appannie.com)
  • 43. Testight (http://testightapp.com)
  • 44.
  • 45. window.rootViewController - UIViewController :- UINavigationController- UITabBarController- presentModalViewController () InterfaceBuilder - UIView
  • 46. png- @2x retina- , : 44px
  • 47. XML JSON Documents Caches - NSUserDefaults CoreData ASIHTTPRequest
  • 48. AppStore iOS AppStore Review Guidelineshttps://developer.apple.com/appstore/guidelines.html
  • 49. http://habrahabr.ru/post/118282/
  • 50.
  • 51. iTunesU Stanford University, CS 193Phttp://www.stanford.edu/class/cs193p
  • 52. iTunesU WWDC videoshttps://developer.apple.com/videos/wwdc/2011/
  • 53. http://www.raywenderlich.com/
  • 54. http://stackoverow.com/
  • 55. ! gleb34@gmail.com twitter.com/pilot34