UIScreenEdgePanGestureRecognizer继承自UIPanGestureRecognizer ,它可以让你从屏幕边界即可检测手势。
使用新的手势识别器很简单,见以下:
UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc]
initWithTarget:selfaction:@selector(touchmomo:)];
recognizer.edges =UIRectEdgeLeft;
[self.viewaddGestureRecognizer:recognizer];
UIScrollView *suc = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
suc.backgroundColor = [UIColor grayColor];
//当UIScrollView开始滑动的时候,取消键盘事件。
suc.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
//当UIScrollView向下滑动,并且手指接触到键盘的时候,键盘随手指一起滑动,并且在键盘有下滑趋势时松开手指,即取消键盘事件;在键盘 有上滑趋势时松开手,键盘仍在。
suc.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
//无效果
suc.keyboardDismissMode = UIScrollViewKeyboardDismissModeNone;
suc.contentSize = CGSizeMake(320, 800);
UITextField *la = [[UITextField alloc] initWithFrame:CGRectMake(20, 400, 100, 120)];
la.backgroundColor = [UIColor redColor];
[suc addSubview:la];
[self.view addSubview:suc]