Leave the code related to creation and initialization of _postContentUIWV
inside the viewDidLoad
method:
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect rect = _postContentView.bounds;
_postContentUIWV = [[UIWebView alloc] initWithFrame:rect];
_postContentUIWV.delegate = self;
[_postContentUIWV loadHTMLString:selectedPostCD.content baseURL:nil];
[_postContentView addSubview:_postContentUIWV];
}
Move the code related to evaluation of jsString
to the webViewDidFinishLoad
method:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
int fontSize = 30;
NSString *jsString = [[NSString alloc] initWithFormat:
@"document.getElementsByTagName('span')[0].style.webkitTextSizeAdjust='%d%%'",
fontSize];
[_postContentUIWV stringByEvaluatingJavaScriptFromString:jsString];
}