【问题标题】:How to create hotlinks on image?如何在图像上创建热链接?
【发布时间】:2009-04-09 22:36:30
【问题描述】:

我不确定它的 iPhone 版本叫什么,但在 HTML 中它是一个图像映射。地图的某些区域会将您引导至不同的页面。我想使用一个图像,主要是在滚动视图中,我可以让某些区域执行不同的操作。例如,Chemical Touch,http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=288060442&mt=8,就是这样做的。单击一个元素,它会变大以显示更多细节。这种技术叫什么?它是如何产生的?

我想与用户进行更多的互动,我该怎么做:

  • 将地图图钉放到这张图片上
  • 根据我在该区域中是否有文本显示 UITextField
  • 根据用户操作叠加文本

非常感谢这里的任何建议。

【问题讨论】:

    标签: iphone cocoa-touch uiscrollview uiimage


    【解决方案1】:

    您基本上需要做的是覆盖任何或全部:

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
    - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
    

    在您的 UIView 子类(或者实际上是 UIResponder 的任何子类)中。然后你可以随心所欲地处理事件,例如做你在问题中提到的任何事情。

    例如,以下是 Apple 的简单事件处理程序示例代码:

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch* touch = [touches anyObject];
        NSUInteger numTaps = [touch tapCount];
        if (numTaps < 2) {
            [self.nextResponder touchesBegan:touches withEvent:event];
       } else {
            [self handleDoubleTap:touch];
       }
    }
    

    iPhone 应用程序编程指南中的Event Handling 部分应为您提供入门所需的所有信息。

    【讨论】:

    • 如果您通过 locationInView 获取点击位置,那么在调整图像大小时会发生什么?您正在寻找的位置现在已经发生了一些变化。
    • locationInView 会告诉您点击发生时的位置,并且如果视图发生更改,则不会更改,因为视图更改发生在点击之后。
    猜你喜欢
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-16
    • 1970-01-01
    • 2016-10-16
    相关资源
    最近更新 更多