2009-04-09 73 views
1

我不确定iPhone的版本是什么,但在HTML中它是一个图像映射。地图的某些区域将您路由到不同的页面。我想使用一个图像,主要是在滚动视图中,我可以让某些区域执行不同的操作。例如,Chemical Touch,http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=288060442&mt=8,这样做。点击一个元素,它的大小会增加以显示更多细节。这种技术称为什么?它是如何创建的?如何在图像上创建热链接?

我想与用户多一点互动,我该怎么做这些:

  • 降地图销到这一形象
  • 显示取决于如果我有文字的UITextField根据用户的操作

这里的任何建议,区域

  • 叠加文本是极大的赞赏。

  • 回答

    1

    什么你基本上需要做的是覆盖任何或全部的:在你的UIView子类(或实际上任何UIResponder的子类)

    - (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; 
    

    。然后,您可以根据自己的意愿处理事件,例如执行您在问题中提到的任何事情。

    例如,这里是苹果的一个简单的事件处理程序的示例代码:

    - (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节应该给你你需要开始所有的信息。

    +0

    如果您通过locationInView获取水龙头位置,当图像调整大小时会发生什么?你正在寻找的位置现在已经转移了一些可变数量。 – 4thSpace 2009-04-11 06:22:05