2012-01-17 24 views
0

我試着嘗試運行該項目何時實現你的實現我的項目是一個名爲「庫」按鈕,但收到一個錯誤。MWPhotoBrowser

我實現文件看起來是這樣的。

-(IBAction) gallery{ 


    NSMutableArray *photos = [[NSMutableArray alloc] init]; 

MWPhoto *photo; 

{ 

    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"fans1" ofType:@"jpg"]]; 

    photo.caption = @"My fans 1"; 

    [photos addObject:photo]; 

    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"fans2" ofType:@"jpg"]]; 

    photo.caption = @"My fans 2"; 

    [photos addObject:photo]; 

    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"fans3" ofType:@"jpg"]]; 

    photo.caption = @"Fans3"; 

    [photos addObject:photo]; 

    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"fans4" ofType:@"jpg"]]; 

    photo.caption = @"Fans4"; 

    [photos addObject:photo]; 


} 






    self.photos = photos; 



    // Create browser 

    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self]; 

browser.displayActionButton = YES; 

    //browser.wantsFullScreenLayout = NO; 

    //[browser setInitialPageIndex:2]; 



    // Show 

    if (_segmentedControl.selectedSegmentIndex == 0) { 

// Push 

[self.navigationController pushViewController:browser animated:YES]; 

    } else { 

// Modal 

UINavigationController *nc = [[UINavigationController alloc]    initWithRootViewController:browser]; 

    nc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 

[self presentModalViewController:nc animated:YES]; 

    } 

    } 

    #pragma mark - MWPhotoBrowserDelegate 

    - (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser { 

    return _photos.count; 

    } 



    - (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex: (NSUInteger)index { 

     if (index < _photos.count) 

     return [_photos objectAtIndex:index]; 

    return nil; 

    } 

當我運行該項目,但圖像庫沒有顯示。我相當新的ioS開發。如果你能指點我在正確的方向,我將深深感激它。主要目標是有圖像庫當用戶觸摸圖庫按鈕時顯示。

我從MWPhotoBrowser演示項目文件複製並編輯了代碼我沒有收到任何錯誤,但我無法讓畫廊在按鈕被觸摸時出現。 (順便說一下,我將IBACTION分配給按鈕)。如果有另一個源代碼或替代框架,我可以使用,請告知。謝謝!

回答

0

想法:

1)嘗試使用'initWithPhotos'。

2)在你推動的地方放一個斷點,檢查是否被調用。

3)在調試時檢查navigationController是否爲空(0x0)。

4)記得發佈'瀏覽器'。

相關問題