【发布时间】:2012-02-24 10:35:15
【问题描述】:
我使用了 4 张图像并使用 touches started 方法来检测用户对特定图像的触摸。我根据触摸位置导航到 4 个不同的视图。苹果会认可他的这种设计吗?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint touchLocation = [touch locationInView:self.view];
CGRect rectLocation1 = CGRectMake(20, 399, 72, 61);
CGRect rectLocation2 = CGRectMake(91, 399, 72, 61);
if (CGRectContainsPoint(rectLocation1, touchLocation)) {
//navigation
}
if (CGRectContainsPoint(rectLocation2, touchLocation)) {
//Navigation
}
}
【问题讨论】:
-
我认为这没有任何问题。但是为什么你不能使用 4 个按钮来代替,使用图像作为按钮的背景。这样会顺畅很多。还是你的图片不是矩形的?
-
在这种情况下我无法使用按钮,因为我已获得 1 个默认图像和 4 个选定状态图像。单个图像具有 4 个按钮的印象。每个选定的状态图像将有一个缩小按钮,其他 3 个按钮与正常状态图像一样正常。我将根据用户在正常状态图像中单击的位置将这 4 个选定状态图像分配给图像视图,从而给用户一种他们正在单击按钮的错觉。
标签: iphone uiimageview navigation uitouch