0
私の実装ファイルは、次のようになります。
-(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を割り当てました)。別のソースコードまたは別のフレームワークがある場合は、私に助言してください。ありがとう!