相关疑难解决方法(0)

UIImageView上的UIGestureRecognizer

我有一个UIImageView,我希望能够调整大小和旋转等.

可以UIGestureRecognizer添加到UIImageView

我想UIImageView在运行时创建一个旋转和捏合识别器.

如何添加这些识别器?

objective-c uiimageview uigesturerecognizer ios

176
推荐指数
5
解决办法
10万
查看次数

UIImage检测触摸和拖动

相当常见的问题,我有几个答案,我几乎就在那里.我有一个按钮,按下后,将创建一个图像(代码如下)

(numImages在加载时设置为ZERO,用作所有图像的标记号的计数)

UIImage *tmpImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%i.png", sender.tag]] retain];
UIImageView *myImage = [[UIImageView alloc] initWithImage:tmpImage];

numImages += 1;

myImage.userInteractionEnabled = YES;
myImage.tag = numImages;
myImage.opaque = YES;
[self.view addSubview:myImage];
[myImage release];
Run Code Online (Sandbox Code Playgroud)

然后我有一个touchesBegan方法,它将检测触摸的内容.我需要它做的是允许用户拖动新创建的图像.它几乎可以正常工作,但拖动它时图像会闪烁不已.我可以访问你点击的图像,因为我可以得到它的标签,但我不能很好地拖动它.

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [[event allTouches] anyObject];
    CGPoint location = [touch locationInView:touch.view];

    if (touch.view.tag > 0) {
        touch.view.center = location;
    }

    NSLog(@"tag=%@", [NSString stringWithFormat:@"%i", touch.view.tag]);

}

- (void) touchesMoved:(NSSet *)touches withEvent: (UIEvent *)event {
    [self touchesBegan:touches withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)

它的工作原理是,当我点击它们时,我得到每个图像的标签输出.但是当我拖动时,它闪烁......任何想法?

iphone touch uiimageview

8
推荐指数
1
解决办法
3万
查看次数

对iPhone中的图像采取行动

我正在创建一个程序,我在视图中添加一个图像视图,我想只在点击图像后,应该出现另一个细节视图.

NSString *imageName = [NSString stringWithFormat:[dic objectForKey:@"img"]]; 
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubView:imageView];
Run Code Online (Sandbox Code Playgroud)

详细视图应与导航控制器一起显示.请帮我解决这个问题

iphone ios

3
推荐指数
1
解决办法
3406
查看次数