Handling some process under Touch event during when particular UI control interaction:
Whenever we want to do some process under touch event, we can follow that under
"- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event"
But when we have a UIControl like UILabels, Imagebuttons etc. and we want to do some process when Touch events occurred on that particular UIControls, following the below process to do it.
1. Create a UIControl. For example: UILabel
2. Link UILabel with declaration property in code. Make sure UserInteraction checkbox is enabled for UILabel in I.B
3. Add the below code in your code.
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint point = [[touches anyObject] locationInView:urlLabel];
if( [urlLabel hitTest:point withEvent:nil] )
[ [UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.mywebsite.com"] ];
else
[super touchesEnded:touches withEvent:event];
}
What it does is, whenever touch event is happening on the UILabel, it will launch the URL website given.
You got to go ... and be success !!!!!!!
Thank you.
Cheers!
M.P.Prabakar
Senior Systems Analyst
No comments:
Post a Comment