一切都在我的代码中工作,但我总是警告"swipeLeft.delegate = self;"
这个警告标志着"自我".
警告是:将'UIWebView*'传递给不兼容类型的参数
和
将'viewCont*const __strong'传递给不兼容类型的参数"id UIGestureRecognizerDelegate
我能做什么??
我的代码:
#import "viewCont.h"
@implementation viewCont
@synthesize webView = webView_;
- (void)viewDidLoad
{
//...code
// add Left
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.delegate = self;
[webView_ addGestureRecognizer:swipeLeft];
//code....
}
Run Code Online (Sandbox Code Playgroud) 我听说UISwipeGestureRecognizer可以用来区分慢速滑动和快速滑动。但我找不到任何 API 来区分。
我在touchesEnded方法中调用了一个名为addProjectile的方法.addProjectile接收touchesEnded方法接收的触摸的NSSet.为简单起见,我只在相关代码中发布了我的问题.所以,要明确一点:
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[self addProjectile:touches]; }
-(void) addProjectile:(NSSet *)touches {//do stuff }
Run Code Online (Sandbox Code Playgroud)
我想在名为swipeRight的UIPanGestureRecognizer方法的末尾调用addProjectile并发送正确的NSSet触摸.
-(void)swipedRight:(UIPanGestureRecognizer *)recognizer {
CGPoint panned=[recognizer translationInView:self.view];
if(panned.x>50){//do stuff }
else {
NSSet *touches; <-- this is what I need to get
[self addProjectile:touches];
Run Code Online (Sandbox Code Playgroud)
所以我的问题是如何在swipedRight结束时获得正确的NSSet触摸(这是用户拿起他/她的手指):正确执行addProjectile方法.
我正在尝试制作由 a 触发的自定义交互式过渡,UISwipeGestureRecognizer但状态始终为UIGestureRecognizerStateEnded,因此我无法使用它来控制动画。
Apple 的文档说Some of these states are not applicable to discrete gestures但他们没有说哪些状态可用于UISwipeGestureRecognizer. [ https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/index.html#//apple_ref/occ/instp/UIGestureRecognizer/state]
难道UISwipeGestureRecognizer只能有一个状态还是我做错了什么?
如何在同一个 View-iOS 上检测 UISwipeGestureRecognizer 2 手指滑动或 3 手指滑动
任何人有想法?
在我的iOS应用程序中,我有以下设置:
- (void)setupGestures
{
UIPanGestureRecognizer* panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
[self.view addGestureRecognizer:panRecognizer];
UISwipeGestureRecognizer* swipeUpRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
[swipeUpRecognizer setDirection:UISwipeGestureRecognizerDirectionUp];
[self.view addGestureRecognizer:swipeUpRecognizer];
}
// then I have following implementation of selectors
// this method supposed to give me the length of the swipe
- (void)panGesture:(UIPanGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateBegan)
{
startLocation = [sender locationInView:self.view];
}
else if (sender.state == UIGestureRecognizerStateEnded)
{
CGPoint stopLocation = [sender locationInView:self.view];
CGFloat dx = stopLocation.x - startLocation.x;
CGFloat dy = stopLocation.y …Run Code Online (Sandbox Code Playgroud) 我目前正面临一个场景,我UIPageViewController在视图上使用了一个场景,当用户从索引值向右滑动时我想要正确的滑动手势0,所以我试图UIPageViewController通过以下代码添加右侧滑动手势:
UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];
//Edit 1
[self.pageViewController.view addGestureRecognizer:rightRecognizer];
Run Code Online (Sandbox Code Playgroud)
但是,当我添加手势时,pageviewcontroller我收到以下错误消息(由@Lyndsey Scott解答)
no visible interface uipageviewcontroller declares the selector addgesturerecognizer
Run Code Online (Sandbox Code Playgroud)
任何人都可以指导我如何在此实现正确的滑动 pageViewController
编辑1:替换了@Lyndsey Scott提供的代码,删除了错误,但问题仍然存在,我无法触发该滑动事件.
objective-c ios uiswipegesturerecognizer uipageviewcontroller
注意:这是iOS 13 beta,但也可能会在明天正式发布。
更新2:我将其替换为较大的缩略图,但仍然有问题。
更新:如果我非常精确地触摸滑块上的拇指,它似乎仍然可以连续控制。但是,为什么要更改此设置?如何使它像以前一样进行控制?
我向视图添加了滑动手势识别器:
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
swipeRight.direction = UISwipeGestureRecognizer.Direction.right
self.view.addGestureRecognizer(swipeRight)
Run Code Online (Sandbox Code Playgroud)
稍后,我将UISlider添加到同一视图:
let slider = UISlider()
let sliderLength:CGFloat = 175
slider.frame = CGRect(x:0,
y:CGFloat(customHeight) - 35,
width:sliderLength,
height:35)
slider.minimumValue = -1.2
slider.maximumValue = 0.6
slider.setValue(Float(snowSliderValAdder), animated: false)
slider.addTarget(self, action: #selector(self.updateSnowSliderValue(_:)), for: .valueChanged)
view.addSubview(slider)
Run Code Online (Sandbox Code Playgroud)
以前可以正常运行的东西现在在iOS 13中表现不佳。如果我将其缓慢移动,则可以移动滑块上的拇指,但是如果进行任何滑动动作,则滑块上的拇指会停止移动,并且手势为触发。我该如何阻止这种情况的发生?