zoukankan      html  css  js  c++  java
  • Using UIGestureRecognizer

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.   
    
        [MoveMe.titleLabel setText:NSLocalizedString(@"Move Me Now!",@"")];
    
      // Init
    UIPanGestureRecognizer * mPanGR = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onMoveMePan:)];
     // add To MoveMe [MoveMe addGestureRecognizer:mPanGR]; } - (void) onMoveMePan:(UIPanGestureRecognizer *)gestureRecognizer { UIView * v = [gestureRecognizer view]; if (v == MoveMe ) {
        //Get Locations Before Modify Any Thing ,!!! It'w may reset locations while you change other options,such like Text CGPoint translation
    = [gestureRecognizer translationInView:[v superview]]; CGPoint center= MoveMe.center; if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) { [MoveMe.titleLabel setText:NSLocalizedString(@"Moving!",@"")]; //Move !!! must be happen after alter other options; translation.x += center.x; translation.y += center.y; v.center = translation; } if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) { MoveMe.titleLabel.text = NSLocalizedString(@"Move End",@"");
            //Move translation.x
    += center.x; translation.y += center.y; v.center = translation; }
          // reset the Offect Vector to zero offter handled [gestureRecognizer setTranslation:CGPointZero inView:v.superview]; } }
    - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)dealloc { [MoveMe release]; [super dealloc]; }
  • 相关阅读:
    jzoj3294. 【SHTSC2013】超级跳马
    jzoj3243. Cube
    jzoj3242. Spacing
    jzoj3232. 【佛山市选2013】排列
    jzoj3297. 【SDOI2013】逃考
    jzoj4800. 【GDOI2017模拟9.24】周末晚会
    学习burnside、polya小结
    学习splay或spaly小结
    一个初学者的辛酸路程-了解Python-2
    一个初学者的辛酸路程-初识Python-1
  • 原文地址:https://www.cnblogs.com/playerc/p/using_uigesturerecognizer.html
Copyright © 2011-2022 走看看