I am importing all tags of a HTML page to UITextView. but i have few on click events like mail and phone in this HTML tags. how can i detect that on click event and open it in UIWebView.
- 7,230
 - 11
 - 38
 - 59
 
- 401
 - 5
 - 18
 
- 
                    Have a look in this http://stackoverflow.com/questions/2543967/how-to-intercept-click-on-link-in-uitextview – fibnochi Jan 02 '13 at 12:49
 - 
                    no not same question, i want to call a action which is in HTML into iphone programming – Pradeep Kumar Jan 02 '13 at 13:21
 - 
                    do you edit your textview? if no then use textview delegate methods. Also have a look on this http://benscheirman.com/2009/07/detecting-a-tap-on-a-uitextview – fibnochi Jan 02 '13 at 13:28
 - 
                    you mean you want to display string in to UIWebView in some porsion like hyperlink and you want to get clickivent of it right...? then i provide some code if you want like this..? – Nitin Gohel Jan 02 '13 at 13:33
 - 
                    @fibnochi: i am fine with UITextview and links in UITextview. i want to import "on Click" event from HTML to ios. – Pradeep Kumar Jan 02 '13 at 13:38
 - 
                    @NitinGohel: were is the code nitin? thanks in advance – Pradeep Kumar Jan 02 '13 at 13:40
 - 
                    wait i just put my answer – Nitin Gohel Jan 02 '13 at 13:40
 - 
                    you have to right your own javascript functions to detect tap event. I have done similar thing but I used UIWebView. – fibnochi Jan 02 '13 at 13:46
 - 
                    display your string into `WebView` its better and easy to use as par my answer – Nitin Gohel Jan 02 '13 at 13:58
 
2 Answers
When you on click events, do you simply mean that you want to make things like the email address, phone # etc to be tappable, such that tapping a phone # would open the Phone app etc?
If so, have you tried simply setting the UITextView's properties in Interface Builder > Attributes Inspector.
See my image below:

- 1,095
 - 2
 - 11
 - 17
 
- 
                    thank you, but how can i call a event in HTML(in apple words:IBAction in HTML into ios) – Pradeep Kumar Jan 02 '13 at 13:20
 
suppose are you displaying String in UIWebView like bellow But First you must configure your webView outlet and connect proper Delegate then put below code in to ViewWillApear:-
[webview loadHTMLString:[NSString stringWithFormat:@"%@
Have an enquiry for %@? Click hear and we will be in touch with you.* {margin:0;padding:0; font-family:Arial;font-size:15px;text-align:justify}", yourStringDiscription,YourHyperlinkWord] baseURL:nil];
in Above script this line:-
:[NSString stringWithFormat:@"<html><body  text=\"#000000\">%@ <br>Have an enquiry for %@? Click <a href=\"inapp://\">hear</a> 
in first %@ is for String of contain and second %@ for your Hyparlink
Now
you can get click event of this webViewdelegate method
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
    if ( inType == UIWebViewNavigationTypeLinkClicked ) {
       //Got even here put breck point
       return NO;
    }
    return YES;
}
you can got click event in above delegate hope you undastood what i am saying and hope its help's you
- 49,482
 - 17
 - 105
 - 144