0

AQGridViewドキュメントディレクトリ内のファイルを、事前定義されて起動時にテーブルに読み込まれる他の 4 つのドキュメントとともに表示するように設定しました。ドキュメントの URL を保持するようにセルを設定する方法を知る必要があります (はい、定義済みの URL も含まれます!結局のところ、それらはすべてNSStringsです)。

- (void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index { 
    NSString *fileURL = [self._icons objectAtIndex:index]; 
    // do stuff
}

カスタム-(id)initメソッドで新しいビューにロードされます。現在、NSLogドキュメント ディレクトリ オブジェクト セルの は を返し、(NULL)SIGABRTログに記録されています。


よし、報奨金が上がった。これは、少しの品質を要求できることを意味すると思います。コードスニペットは素晴らしいでしょう!

リクエストに応じて利用可能なコード。

作業コードを編集:

//.h    
NSMutableArray *_documentIconsURLs;

//.m
//viewDidLoad
 // array for internal and external document URLs
    self._documentIconsURLs = [NSMutableArray array];
        _documentIconsURLs = [[NSMutableArray alloc] initWithObjects:@"Musette.pdf",
                              @"Minore.pdf",
                              @"Cantata.pdf",
                              @"Finalé.pdf",
                              @"divine-comedy-inferno.pdf", nil];
//didSelectObject
- (void) gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index {

    NSLog (@"Selected theArgument=%d\n", index);

    UIViewController *viewController = [[[UIViewController alloc]init]autorelease];
    {
        //if file is built-in, read from the bundle
        if (index <= 4)
        {
            // first section is our build-in documents
            NSString *fileURLs = [_documentIconsURLs objectAtIndex:index];
            NSLog(@"%@", fileURLs);
            viewController = [[[viewController alloc]initWithContentURL:fileURLs]autorelease];
        }
4

1 に答える 1