C#基本之Lambda表達式用法實例教程。本站提示廣大學習愛好者:(C#基本之Lambda表達式用法實例教程)文章只能為提供參考,不一定能成為您想要的結果。以下是C#基本之Lambda表達式用法實例教程正文
一,工程圖。
二,後果圖。
三,代碼。
RootViewController.h
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UIGestureRecognizerDelegate> @end
RootViewController.m
#import "RootViewController.h" @interface RootViewController () @end @implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //增長配景圖 [self addView]; } #pragma -mark -functions //配景圖 -(void)addView { //白色的配景圖 UIView *parentView=[[UIView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)]; parentView.backgroundColor=[UIColor redColor]; [self.view addSubview:parentView]; [parentView setUserInteractionEnabled:YES]; //挪動的手勢 UIPanGestureRecognizer *panRcognize=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; panRcognize.delegate=self; [panRcognize setEnabled:YES]; [panRcognize delaysTouchesEnded]; [panRcognize cancelsTouchesInView]; [parentView addGestureRecognizer:panRcognize]; } #pragma UIGestureRecognizer Handles - (void)handlePan:(UIPanGestureRecognizer *)recognizer { NSLog(@"--挪動的手勢-----"); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
以上代碼是有關Android法式開辟之給配景圖加上挪動的手勢的全體內容,願望對年夜家有所贊助!