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

首頁(yè) > 系統(tǒng) > iOS > 正文

IOS 單擊手勢(shì)的添加實(shí)現(xiàn)代碼

2019-10-21 18:46:28
字體:
供稿:網(wǎng)友

IOS 單擊手勢(shì)的添加實(shí)現(xiàn)代碼

一,效果圖。

iOS,單擊手勢(shì)的添加,單擊手勢(shì),添加手勢(shì)

二,工程圖。

iOS,單擊手勢(shì)的添加,單擊手勢(shì),添加手勢(shì)

三,代碼。

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=@"單擊手勢(shì)的添加";    UIView *parentView=[[UIView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];  parentView.backgroundColor=[UIColor redColor];  [self.view addSubview:parentView];    //單擊的手勢(shì)  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(@"---單擊手勢(shì)-------");}- (void)didReceiveMemoryWarning{  [super didReceiveMemoryWarning];  // Dispose of any resources that can be recreated.}

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


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到IOS開發(fā)頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 灵璧县| 罗定市| 汉中市| 尉氏县| 道真| 丹东市| 和硕县| 商洛市| 曲松县| 湘潭市| 永福县| 咸宁市| 嘉鱼县| 上思县| 河曲县| 泾源县| 隆安县| 达日县| 东山县| 萨迦县| 视频| 册亨县| 永川市| 玛多县| 福州市| 通化县| 同江市| 嵊泗县| 辽中县| 旌德县| 威宁| 光山县| 固镇县| 宽城| 望城县| 忻州市| 宝丰县| 阳谷县| 金乡县| 景洪市| 信阳市|