I am trying to call a javascript function from a popover using a UITableView containing NSArray fonts in an iPad. The problem I am facing is that whenever I call a function from didselectrowatindexpath, it cannot compose anything in the UIWebView. I can get the relevant information in NSLog, but for some reason the connection between the two views is not fulfilled. If I assign a function to a button in a view containing a UIWebView, everything will be fine. I use a storyboard, and popovervew and UIWebView have the same viewController class. It may be something very simple that I forgot, but I really got stuck for any reason. Also, if I call some other function, such as a warning, everything works as expected. I am sincerely grateful for any help in this matter. Thanks
This is how I call the javascript function in the didselectrowatindexpath file:
- (void) tableView: (UITableView *) theTableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
UITableViewCell *selectedCell = [self.myTableView cellForRowAtIndexPath:indexPath];
NSString *cellText1 = selectedCell.textLabel.text;
[myWebView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"tinymce.activeEditor.execCommand('fontName', false, '%@');", cellText1]];
NSLog (@"%@", cellText1);
[self.myTableView deselectRowAtIndexPath: indexPath animated: YES];
}
Here is the button code in a view containing a UIWebView that sets the font to "Arial":
-(IBAction)changeFont:(id)sender{
[myWebView stringByEvaluatingJavaScriptFromString:@"tinymce.activeEditor.execCommand('fontName', false, 'Arial');"];
}
source
share