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]; }
  • 相关阅读:
    random模块
    collections模块
    re模块
    正则表达式
    递归函数,二分查找
    内置函数,匿名函数
    python 中的爬虫· scrapy框架 重要的组件的介绍
    flask 中的常用组件的使用 ,virtualenv组件和 pipreqs组件 和 偏函数
    Django 中自带的 content_type表 , alipay的接口 需要的配置
    restful 和 restframework
  • 原文地址:https://www.cnblogs.com/playerc/p/using_uigesturerecognizer.html
Copyright © 2011-2022 走看看