私はのUIWebViewでクリックされたボタンを判断する方法を知りたいこの時間は.....uiwebviewでjavascriptを使用してクリックされたボタンIDを取得する方法は?
appDelegate.mystring = [[NSMutableString string]init];
NSString *[email protected]"<label><input type=\"submit\" name=\"button\" id=\"1\" value=\"Delete\" /></label>";
for (int i=0; i<appDelegate.lyricsData.count; i++) {
NSString *b= @"<br>";
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:@"<html><head><meta name=\"viewport\" content=\"width=200; initial-scale=1.0; maximum-scale=0; user-scalable=0;\" /> </head> <style> *{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; } </style> <body> <div class=\"wrap\"> <div class=\"head\"> <div class=\"head-left\"><img src=\"%@\" width=\"54\" height=\"54\" /></div> <div class=\"head-right\"> <h1>%@</h1> <h2>%@</h2> <small>on %@</small> </div> <br clear=\"all\" /> </div> <div class=\"status\"><b>%@</b><div class=\"comments\"><h2>%@ </h2></div><br clear=\"all\" /> </div></div> </body></html>",
appDelegate.profilepic,appDelegate.textfield,appDelegate.username,appDelegate.added_date,appDelegate.mytextview,appDelegate.mystring];
[mywebview loadHTMLString:htmlTempString baseURL:nil];
mywebview.delegate=self;
///ボタンのコード
- (IBAction)buttonClick:(id)sender{
NSLog(@"button %@",[sender tag]);
}