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

  • Published on
    08-May-2015

  • View
    1.094

  • Download
    3

Embed Size (px)

Transcript

  • 1. iOS 3 () ,

2. 3. UINavigationController 4. ViewController *c = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:self.viewController]; 5. - (IBAction)buttonTapped{UIViewController *c =[[SubViewController alloc] initWithNibName:@"SubViewController"bundle:nil];[self.navigationController pushViewController:c animated:YES];} 6. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{self = [super initWithNibName:nibNameOrNilbundle:nibBundleOrNil];if (self){self.title = @"ViewController";}return self;} 7. UITabBarController 8. ViewController *c = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];SubViewController *s = [[SubViewController alloc] initWithNibName:@"SubViewController"bundle:nil];UITabBarController *tc = [[UITabBarController alloc] init];tc.viewControllers = [NSArray arrayWithObjects:c, s, nil]; 9. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{self = [super initWithNibName:nibNameOrNilbundle:nibBundleOrNil];if (self){self.title = @"ViewController";self.tabBarItem.image = [UIImageimageNamed:@"1.png"];}return self;} 10. UIPageViewController 11. StoryBoard() 12. 13. http://mobile-patterns.com 14. Tabs 15. Dashboard 16. UITableView + UINavigationController : 17. Widget 18. News360 19. 20. UIGestureRecognizerUIView:- (void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer 21. UITapGestureRecognizerUITapGestureRecognizer *t = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped)];t.numberOfTapsRequired = 1;t.numberOfTouchesRequired = 1;[self.view addGestureRecognizer:t]; 22. UIPanGestureRecognizerUIPanGestureRecognizer *p = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];[self.view addGestureRecognizer:p];- (void)pan:(UIPanGestureRecognizer *)sender{CGPoint t = [sender translationInView:self.view];CGPoint v = [sender velocityInView:self.view];NSLog(@"%@", NSStringFromCGPoint(t));NSLog(@"%@", NSStringFromCGPoint(v));} 23. UIPinchGestureRecognizerUIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];[self.view addGestureRecognizer:pinch];- (void)pinch:(UIPinchGestureRecognizer *)sender{CGFloat scale = sender.scale;NSLog(@"%g", scale);} 24. UIRotationGestureRecognizerUIRotationGestureRecognizer *r = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];[self.view addGestureRecognizer:r];- (void)rotate:(UIRotationGestureRecognizer *)sender{CGFloat r = sender.rotation;NSLog(@"%g", r);} 25. UISwipeGestureRecognizer *s = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];s.direction = UISwipeGestureRecognizerDirectionLeft;[self.view addGestureRecognizer:s]; UISwipeGestureRecognizer UILongPressGestureRecognizerUILongPressGestureRecognizer *p = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];p.minimumPressDuration = 0.5;[self.view addGestureRecognizer:p]; 26. UIGestureRecognizerDelegate- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizershouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizershouldReceiveTouch:(UITouch *)touch; 27. UIGestureRecognizerStatetypedef enum {UIGestureRecognizerStatePossible,UIGestureRecognizerStateBegan,UIGestureRecognizerStateChanged,UIGestureRecognizerStateEnded,UIGestureRecognizerStateCancelled,UIGestureRecognizerStateFailed,UIGestureRecognizerStateRecognized =UIGestureRecognizerStateEnded} UIGestureRecognizerState; 28. 29. [UIView beginAnimations:nil context:nil];[UIView setAnimationDuration:0.5];self.view.frame = CGRectMake(100, 100, 50, 50);[UIView commitAnimations];[UIView beginAnimations:nil context:nil];self.view.alpha = 0;[UIView commitAnimations]; 30. [UIView beginAnimations:nil context:nil];[UIView setAnimationDelegate:self];[UIView setAnimationDidStopSelector:@selector(animationFinished)];self.view.alpha = 0;[UIView commitAnimations];- (void)animationFinished{//...}