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];
}
整個項目實際上是圍繞例如基於。我想要更多的頁面類型的外觀和感覺,所以我擴大了單元格。真正讓我去做的一件事是,如何無法存儲和回調NSString,如應用程序用於運行的UITableView。總之,感謝您的建議,我今晚正在做調試工作,如果我有積極的結果,我會盡快回復您。 – CodaFi
啊!第二個NSArray,這實際上是我的小腦袋放屁就在你發佈之前。同樣,如果整個事情都有積極的結果,就會發布。 – CodaFi
如果你喜歡一個數組,你可以編寫一個簡單的對象,保存名稱和圖標,並將這些對象放在單個數組中。 – vikingosegundo