2011-11-05 21 views
0

我有一個AQGridView設置爲顯示文檔目錄中的文件以及其他4個預定義並在啓動時加載到表中的文檔。我需要知道如何設置單元格來保存文檔的URL(是的,即使是預定義的!他們都只是NSStrings畢竟。),所以它能用NSString在AQGridViewCell中

- (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]; 
     } 

回答

1

對與AQGridView未來的跳板示例代碼看看。

與交流的代碼SpringBoardIconCell和SpringBoardViewController代碼我放在這裏:https://gist.github.com/52c61b9c68e482ec35a1

基本上只需要添加一個UILabel到SpringBoardIconCell,將其添加到視圖層級結構,並設置於從數據源中gridView:cellForItemAtIndex:文本。

最後:

-(void)gridView:(AQGridView *)gridView didDeselectItemAtIndex:(NSUInteger)index 
{ 
    NSString *fileName = [self.fileNames objectAtIndex:index]; 
    //do stuff 
} 
+0

整個項目實際上是圍繞例如基於。我想要更多的頁面類型的外觀和感覺,所以我擴大了單元格。真正讓我去做的一件事是,如何無法存儲和回調NSString,如應用程序用於運行的UITableView。總之,感謝您的建議,我今晚正在做調試工作,如果我有積極的結果,我會盡快回復您。 – CodaFi

+0

啊!第二個NSArray,這實際上是我的小腦袋放屁就在你發佈之前。同樣,如果整個事情都有積極的結果,就會發布。 – CodaFi

+0

如果你喜歡一個數組,你可以編寫一個簡單的對象,保存名稱和圖標,並將這些對象放在單個數組中。 – vikingosegundo