私のアプリには、詳細ビューを含むテーブル ビューがあります。詳細ビューはHEREからブログ投稿を読み込み、詳細ビューにはその投稿のテキストが表示されます。ほとんど機能していますが、テキストを修正する方法を理解する必要があります (以下の例)。詳細ビューでウェブサイトからテキストを取得するために必要なコードは次のとおりです。
-(void)viewDidLoad {
//self.url is from the table view where the link to the website is
NSURL *myURL = [NSURL URLWithString: [self.url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
NSURLRequest *request = [NSURLRequest requestWithURL:myURL];
[self.webView loadRequest:request];
timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(LoadText) userInfo:nil repeats:YES];
}
-(void)webViewDidLoadText {
NSString *textForBlog = [self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('paragraph')[0].innerHTML;"];
self.textView.text = textForBlog;
}