Как я могу открыть файлы documentDirectory (из моего UITableView) в UIWebView? - PullRequest
0 голосов
/ 05 декабря 2011

Я бы хотел, чтобы мои файлы из моего каталога документов iOS (файлы перечислены в моем UITableView) были доступны, поэтому при нажатии UIWebView загрузит этот файл (в автономном режиме).

Как я могу это сделатьэто?

1 Ответ

2 голосов
/ 05 декабря 2011
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *pathForYourFile = [documentsDirectory stringByAppendingPathComponent:[filePathsArray objectAtIndex:indexPath.row]];

[yourWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:pathForYourFile ofType:@"html"]isDirectory:NO]]]; 

}

См. Этот документ, чтобы узнать форматы файлов, поддерживаемые UIWebView

http://developer.apple.com/library/ios/#qa/qa1630/_index.html

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...