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]; }
  • 相关阅读:
    链接唤醒IOSApp
    C#抽象属性
    c#结构体与类的区别
    广告学入门
    个性化推荐十大挑战[
    MapReduce 读取和操作HBase中的数据
    mysql sql命令大全
    从B 树、B+ 树、B* 树谈到R 树
    MapReduce操作HBase
    Meanshift,聚类算法
  • 原文地址:https://www.cnblogs.com/playerc/p/using_uigesturerecognizer.html
Copyright © 2011-2022 走看看