国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

IOS 單擊手勢的添加實現代碼

2020-07-26 02:49:00
字體:
來源:轉載
供稿:網友

IOS 單擊手勢的添加實現代碼

一,效果圖。

二,工程圖。

三,代碼。

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{  self.title=@"單擊手勢的添加";    UIView *parentView=[[UIView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];  parentView.backgroundColor=[UIColor redColor];  [self.view addSubview:parentView];    //單擊的手勢  UITapGestureRecognizer *tapRecognize = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];  tapRecognize.numberOfTapsRequired = 1;  tapRecognize.delegate = self;  [tapRecognize setEnabled :YES];  [tapRecognize delaysTouchesBegan];  [tapRecognize cancelsTouchesInView];    [self.view addGestureRecognizer:tapRecognize];}#pragma UIGestureRecognizer Handles-(void) handleTap:(UITapGestureRecognizer *)recognizer{  NSLog(@"---單擊手勢-------");}- (void)didReceiveMemoryWarning{  [super didReceiveMemoryWarning];  // Dispose of any resources that can be recreated.}

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 广西| 甘德县| 岗巴县| 喀什市| 南皮县| 黄浦区| 嘉峪关市| 苍溪县| 夹江县| 大冶市| 阳高县| 安塞县| 岳池县| 新民市| 朝阳区| 灵台县| 临颍县| 留坝县| 大安市| 宁津县| 腾冲县| 凤台县| 威远县| 贵定县| 新巴尔虎右旗| 洞头县| 永安市| 贵港市| 武定县| 电白县| 若尔盖县| 西藏| 博野县| 安平县| 桑日县| 海伦市| 区。| 余姚市| 盈江县| 根河市| 天峨县|