Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UISweepGestureRecognitor是否更改视图控制器上的图像视图位置?_Objective C_Uiswipegesturerecognizer - Fatal编程技术网

Objective c UISweepGestureRecognitor是否更改视图控制器上的图像视图位置?

Objective c UISweepGestureRecognitor是否更改视图控制器上的图像视图位置?,objective-c,uiswipegesturerecognizer,Objective C,Uiswipegesturerecognizer,我是一名Objective-C初学者,我在stackoverflow上找到了与我的问题类似的答案,但即使尝试了所有的提示/建议,我还是迷路了 我有一个ibuiimageview,我希望它是这样的,如果用户在这个图像上向上或向下滑动,那么视图控制器上各种图像的位置就会改变 我对UISweepGestureRecognitor编码非常熟悉,所以请以初学者能够理解的方式进行解释。提前非常感谢 更新: @Axeva,我使用了以下代码,没有警告或错误。但是,它在我的模拟器上没有正确执行。这是我的密码: i

我是一名Objective-C初学者,我在stackoverflow上找到了与我的问题类似的答案,但即使尝试了所有的提示/建议,我还是迷路了

我有一个ibuiimageview,我希望它是这样的,如果用户在这个图像上向上或向下滑动,那么视图控制器上各种图像的位置就会改变

我对UISweepGestureRecognitor编码非常熟悉,所以请以初学者能够理解的方式进行解释。提前非常感谢

更新:

@Axeva,我使用了以下代码,没有警告或错误。但是,它在我的模拟器上没有正确执行。这是我的密码:

interface math0 (){
UISwipeGestureRecognizer *swipeUp;}

- (void)viewDidLoad
{
[super viewDidLoad];
swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget: self action: @selector(swipedScreenUp:)];
[swipeUp setNumberOfTouchesRequired: 1];
[swipeUp setDirection: UISwipeGestureRecognizerDirectionUp];
[one addGestureRecognizer: swipeUp];
[swipeUp setEnabled: NO];
}

- (void)swipedScreenUp:(UISwipeGestureRecognizer*)swipeGesture {
// Sampling to see if it works
instructions.text = [NSString stringWithFormat:@"IT WORKED!"];
}
在我的.h文件中,我声明了-(void)swipedScreenUp:(UISwipeGestureRecognitor)swipeUp。在我的故事板上,我设置了我的图像(命名为一个),使其具有可访问性和用户交互功能。 我还尝试了[swipeUp setEnabled:YES];在我的viewDidLoad文件中

你或任何人能告诉我错误在哪里吗?谢谢


试着这样做:

@interface YourViewController () {
    UISwipeGestureRecognizer *swipeLeftToRightGesture;
}


- (void)viewDidLoad {
    [super viewDidLoad];

    swipeLeftToRightGesture = [[UISwipeGestureRecognizer alloc] initWithTarget: self action: @selector(swipedScreenRight:)];
    [swipeLeftToRightGesture setNumberOfTouchesRequired: 1];
    [swipeLeftToRightGesture setDirection: UISwipeGestureRecognizerDirectionRight];
    [[self view] addGestureRecognizer: swipeLeftToRightGesture];
}

- (void)swipedScreenRight:(UISwipeGestureRecognizer*)swipeGesture {
    // Move your image views as desired
}

您可以调整此基本代码,使其完全符合您的要求。(不同的刷卡方向等)

显示您的代码。到底是什么问题?你试过什么?也许您只需要将
userInteractionEnabled
设置为YES即可。感谢您的响应,在我的头文件中,我简单地声明了:IBOutlet UIImageView*swipedObjectOne;我知道我需要用“imageView.userInteractionEnabled=YES;”激活用户交互,但我不确定把这段代码放在哪里我还觉得我需要使用:
-(void)handleswip:(uiswipgestureRecognitizer*)滑动{if(swipe.direction==uiswipgestureRecognitizerDirectionUp){swipedObjectOne.center=CGPointRect(所需位置x,所需位置y);}
此外,我在为我的评论和帖子格式化代码时遇到困难,我向所有人表示歉意,请有限地注释出
[swipeUp setEnabled:NO]
这是我的一个项目复制和粘贴过程中遗留下来的一个错误。还要确保为
one
UIImageView正确设置了插座。谢谢,这非常有帮助。我可以问一下,我该怎么做才能让应用程序用户在特定的图像视图上滑动?澄清一下,如果他/她在特定的图像视图上滑动“A”图像,然后出现“A”动作,但他/她可以选择在“B”图像上滑动,然后出现“B”动作…非常感谢。很高兴听到凯文–上面写着
[[self-view]addgestureRecognitor:swipelefttorightspire];
,将
[self-view]
更改为“A”的名称图像和手势将在该图像上起作用。为“B”图像创建一个不同的图像,以处理在该图像上的滑动等。非常感谢,我希望有一天我可以像你帮助过我一样帮助他人。致以最良好的问候,如果你有时间,请阅读我的更新问题。谢谢先生