0

私は iPhone 開発に不慣れです。アプリケーションでローカルに .csv ファイルを作成し、それをアプリケーション内で表示する必要があるプロジェクトに取り組んでいます。.csv ファイルの作成に成功し、それをドキュメント ディレクトリに保存しました。しかし、問題は、作成後にアプリケーション内で .csv を表示する方法がわからないことです。どんな提案でも大歓迎です。

ありがとう。

4

1 に答える 1

0

ドキュメント ディレクトリに csv を保存している可能性があると思います。UIWebView を使用して、このように csv コンテンツを表示できます。

NSString *filePath = [self documentsDirectoryPath];
filePath = [filePath stringByAppendingPathComponent:@"file.csv"]; //your saved fileName
if ([[NSFileManager defaultManager]fileExistsAtPath:filePath]) {
    [yourWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];
}

次のようにドキュメント ディレクトリ パスを取得します。

- (NSString *)documentsDirectoryPath {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectoryPath = [paths objectAtIndex:0];
    return documentsDirectoryPath;
}
于 2012-08-27T05:53:16.520 に答える