Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use javascript in uiwebview to get the clicked button id?
    primarykey
    data
    text
    <p>This Time i want to know how to determine which button is click in UIWebView..... </p> <pre><code> appDelegate.mystring = [[NSMutableString string]init]; NSString *buttonstring=@"&lt;label&gt;&lt;input type=\"submit\" name=\"button\" id=\"1\" value=\"Delete\" /&gt;&lt;/label&gt;"; for (int i=0; i&lt;appDelegate.lyricsData.count; i++) { NSString *b= @"&lt;br&gt;"; NSString *st1=[[appDelegate.lyricsData objectAtIndex:i] objectForKey:@"user_name"]; appDelegate.mystring=[appDelegate.mystring stringByAppendingString:st1]; appDelegate.mystring=[appDelegate.mystring stringByAppendingString:b]; NSString *st2=[[appDelegate.lyricsData objectAtIndex:i] objectForKey:@"added_date"]; appDelegate.mystring=[appDelegate.mystring stringByAppendingString:st2]; appDelegate.mystring=[appDelegate.mystring stringByAppendingString:b]; NSString *st3=[[appDelegate.lyricsData objectAtIndex:i] objectForKey:@"verse"]; appDelegate.mystring=[appDelegate.mystring stringByAppendingString:st3]; appDelegate.mystring=[appDelegate.mystring stringByAppendingString:buttonstring]; appDelegate.mystring=[appDelegate.mystring stringByAppendingString:b]; appDelegate.mystring=[appDelegate.mystring stringByAppendingString:b]; btn_back1_en.tag = i; NSLog(@"%d",btn_back1_en.tag); [btn_back1_en addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside]; [buttonArray insertObject:btn_back1_en atIndex:i]; [btn_back1_en release]; } NSLog(@"My string %@",appDelegate.mystring); UIWebView *mywebview = [[UIWebView alloc] initWithFrame:CGRectMake(0,70, 320, 240)]; mywebview.backgroundColor=[UIColor clearColor]; mywebview.opaque=NO; mywebview.dataDetectorTypes= UIDataDetectorTypeNone; // working NSString *htmlTempString = [NSString stringWithFormat:@"&lt;html&gt;&lt;head&gt;&lt;meta name=\"viewport\" content=\"width=200; initial-scale=1.0; maximum-scale=0; user-scalable=0;\" /&gt; &lt;/head&gt; &lt;style&gt; *{padding:0px;margin:0px;}.wrap{width:320px;background:#000000;color:#FFFFFF;font-family:'Myriad Pro',Arial, Helvetica, sans-serif; font-size:12px;}.head{ padding:15px 20px;background:url(images/bg.png) repeat-x bottom #383838;display:block; border:1px } .head-left{ float:left; width:54px;}.head-right{float:left; width:224px; clear:right; padding:0px 0px 8px 0px;} h1{ padding:0px; font-size:16px; color:#fff;} h2{ padding:0px; font-size:14px; color:#3a89d3;}small{ font-size:11px; color:#77c900; padding:0px;font-weight:normal;} b{ padding:0px;font-size:16px; color:#fff; }.comments{ background:url(images/bot-line.png) no-repeat bottom left; padding:10px 0px;}.comments h1{ padding:0px;font-size:16px; color:#fff; display:inline}.comments h2{ padding:0px;font-size:14px; color:#3a89d3; display:inline; margin:0px;}.comments small{ font-size:11px; color:#77c900; padding:0px; margin:0px 0px 0px 5px; font-weight:normal; display:inline;} .comments b{ padding:0px; margin:0px 0px 5px 5px; font-size:16px; color:#fff; display:inline} .status{padding:15px 20px;background:url(images/bg.png) repeat-x bottom #383838;display:block; margin:4px 0px; } &lt;/style&gt; &lt;body&gt; &lt;div class=\"wrap\"&gt; &lt;div class=\"head\"&gt; &lt;div class=\"head-left\"&gt;&lt;img src=\"%@\" width=\"54\" height=\"54\" /&gt;&lt;/div&gt; &lt;div class=\"head-right\"&gt; &lt;h1&gt;%@&lt;/h1&gt; &lt;h2&gt;%@&lt;/h2&gt; &lt;small&gt;on %@&lt;/small&gt; &lt;/div&gt; &lt;br clear=\"all\" /&gt; &lt;/div&gt; &lt;div class=\"status\"&gt;&lt;b&gt;%@&lt;/b&gt;&lt;div class=\"comments\"&gt;&lt;h2&gt;%@ &lt;/h2&gt;&lt;/div&gt;&lt;br clear=\"all\" /&gt; &lt;/div&gt;&lt;/div&gt; &lt;/body&gt;&lt;/html&gt;", appDelegate.profilepic,appDelegate.textfield,appDelegate.username,appDelegate.added_date,appDelegate.mytextview,appDelegate.mystring]; [mywebview loadHTMLString:htmlTempString baseURL:nil]; mywebview.delegate=self; </code></pre> <p>///Button Code</p> <pre><code>- (IBAction)buttonClick:(id)sender{ NSLog(@"button %@",[sender tag]); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload