imagemap in objective c - iphone

i want to make something like this
http://www.htmlcodetutorial.com/images/images_famsupp_220.html
and i want to know if there is class to do it in objective c?
thx

if i understood you correctly, you want to have several sensitive points on an image view?
try adding
-(void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
NSLog(#"Touches: %#", touches); //examine this!
}
to your code.
it provides UITouch instances in the touches-set, each having an location point for your views.
checkout
UITouch locationInView:;
regs.

UIWebView supports image maps. If you want a pure Objective-C solution I would recommend using an UIImageView and capture touches where you would like to map the image. Once some one touches the view you can then call the appropriate action.

Related

How to make certain part of image clickable in ios?

In one of my app i am using image for the whole screen. Which can be zoomed to some extent. That image has eight different shapes(includes person,shapes,etc).What i am trying to do is i need to make certain each shape of the image is clickable. Touching each part takes to different screens.I didn't have any idea about how to achieve this. I googled it but no solution.
1.) Is this possible by using co-ordinates(will normal image and zoomed image differ in co-ordinates? How to achieve this by using co-ordinates?
2.) If not what will be the best approach to achieve my goal?
Any ideas/samples is much appreciated.
I would add a UITapGestureRecognizer to the imageView holding your image. And the locationOfTouch:inView: method to determine the coordinates of your touch.
Correct me if i don't understand your question. For me, that should be very simple? Just have couple of buttons which background is clear? And They are all on top of the image.
Check UIResponder and the touches methods in there. You'll probably want to hook in to something like -touchesEnded:withEvent: for detecting when a finger lifts off the screen.
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
CGRect touchLocationInView = [touch locationInView:imageView];
// Do something to check that the rect is valid
// If valid, react to it
}
}
Also, a link to UITouch.

UIWebView touch event not getting fired

I am new to iPhone Developer,
I want to detect touch in my webview so i tried this but this method is not getting fired,
in .h file
#interface EpubReaderViewController : UIViewController
in .m file
...
- (void)sendEvent:(UIEvent *)event{
NSLog(#"Touch detected") ;
}
...
Even i tried this also,
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
NSLog(#"Touches began");
}
Thanks In Advance !
User is going to zoom in and zoom out on the website, as well as touch to click hpyerlinks etc. That'w shy touch methods won't respond for UIWebView.
If you want to enable touch, you might need to subclass UIWebview while it is forbidded in developer docs, check following threads for more discussion-
Handling touches inside UIWebview
https://stackoverflow.com/questions/2122745/how-to-detect-touch-event-in-uiwebview
How to intercept touches events on a MKMapView or UIWebView objects?
Handling touches inside UIWebview
You can go through this tutorial as well -
http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way

Passing touch events to iOS status bar

I have a UIWindow with windowLevel set to UIWindowLevelStatusBar+1. This window has a single semi-transparent view that blocks the status bar. I need to sometimes pass touch events from the view on to the status bar. Any ideas?
So, it seems to be doable with a custom subclass of UIWindow overriding hitTest:withEvent: that manually detects a touch in the subview, and always returns nil.
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if ([event type]==UIEventTypeTouches) {
UIView *v=[super hitTest:point withEvent:event];
if (customSubViewthatCoversStatusBarOnly==v)
//doLotsOfCoolStuff
}
return nil;
}
Status bar recognizes all touches, so there is no breakage with scroll-to-top, return to call, VoiceOver, etc.. And I still get to intercept taps on statusbar.
I hacked this up just now. I will probably upload an update to App Store later this week with a more mature version of this, will see how much complaining Apple will do.
EDIT - 7th April:
Was approved by Apple. Works flawlessly.
You might find this component over on github helpful.
Otherwise, Cocoa with Love blog post is really useful to read perhaps.
As far as I understand this, you should use - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event to implement that behavior. Basically, you either return self if you want to handle the touch event or [super hitTest:point withEvent:event] to let the status bar handle the touch event.
Check out the UIView Class Reference for more.
EDIT: As Jonathan mentioned, Apple might not approve this.

iPhone count finger taps and time between taps

I'm pretty new to iPhone programming, so I'm looking for any pointers (no pun intended), links, search terms, etc. on how to make a very simple app that counts how many times one finger touches the screen and how long between each tap.
Thanks for any help, I know this resembles a lame question seeing as how I have really accomplished anything yet.
rd42
In touchesBegan, use:
NSSet *allTouches = [event allTouches];
int tapCount = [allTouches count];
to retrieve the tap count.
You would then need to save the timestamp of the first tap, and find the difference between the next tap in order to get the time elapsed between them.
You'll want to use touchesBegan: and touchesEnded: methods of UIResponder.
All UIViews are UIResponders. So just override those methods on whatever UIView you want the users to touch. Note that there are four touches methods:
touchesBegan:
touchesMoved:
touchesEnded:
touchesCancelled:
If you override any of them, you are required to override all of them. So for the ones you don't care about, just have practically-empty implementations that just call [super touchesMoved: arg1 withEvent: arg2], etc.

IPhone SDK: detect which touch came first on a 2 touch max application

Coding inside the function
-(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
receiving 2 touches in the "event" variable, how can one detect which touch has lived longer?
i know i could use global variables and in the touchbegin just update these variables, but I rather do it the better way, if there is any.
How about comparing the UITouch timestamp properties?
Eventually I stored pointers to the touches. saving a timestamp manually, found no other way.