我试图建立一个小应用程序。这是一个标签应用程序与3标签:照片,视频,文档每个标签显示一个表视图,以选择画廊,视频,文档是要显示;视频很好。
我在相册上遇到了麻烦。我使用Fgallery,从示例中可以很好地工作:
. h
#import <UIKit/UIKit.h>
#import "FGalleryViewController.h"
@interface FirstViewController : UIViewController <FGalleryViewControllerDelegate, UITableViewDelegate, UITableViewDataSource> {
NSArray *localCaptions;
NSArray *localImages;
NSArray *networkCaptions;
NSArray *networkImages;
FGalleryViewController *localGallery;
FGalleryViewController *networkGallery;
}
@property (nonatomic, strong) UITableView *myTableView;
@end
m
#import "FirstViewController.h"
@implementation FirstViewController
@synthesize myTableView;
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect tableViewRect = self.view.bounds;
UITableView *tableView = [[UITableView alloc]
initWithFrame:tableViewRect
style:UITableViewStylePlain];
self.myTableView = tableView;
self.myTableView.autoresizingMask =
UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleWidth;
[self.view addSubview:self.myTableView];
self.myTableView.dataSource = self;
self.myTableView.delegate = self;
}
和
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog( @"Choix Table");
if( indexPath.row == 0 ) {
NSLog( @"selection 1");
localGallery = [[FGalleryViewController alloc] initWithPhotoSource:self];
[self.navigationController pushViewController:localGallery animated:YES];
}
else if( indexPath.row == 1 ) {
networkGallery = [[FGalleryViewController alloc] initWithPhotoSource:self];
[self.navigationController pushViewController:networkGallery animated:YES];
...
}
我真的不知道如何展示这个画廊。didSelectRowAtIndexPath
是一个从fgallery,我试图修改它来显示视图,但我是新的Objective-C,我卡住了。
任何帮助或指导将不胜感激。
谢谢
我添加了
if( indexPath.row == 0 ) {
NSLog( @"selection 1");
localGallery = [[FGalleryViewController alloc] initWithPhotoSource:self];
// Create the navigation controller and present it modally.
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:localGallery];
[self presentModalViewController:navigationController animated:YES];
视图现在显示ok,但是我缺少后退按钮
在FGalleryViewController。m,我将btn2添加到导航控制器
- (void)setUseThumbnailView:(BOOL)useThumbnailView
{
_useThumbnailView = useThumbnailView;
if( self.navigationController ) {
if (_useThumbnailView) {
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"See All" style:UIBarButtonItemStylePlain target:self action:@selector(handleSeeAllTouch:)] ;
[self.navigationItem setRightBarButtonItem:btn animated:YES];
UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(dismissModalViewControllerAnimated:)] ;
[self.navigationItem setLeftBarButtonItem:btn2 animated:YES];
}
else {
[self.navigationItem setRightBarButtonItem:nil animated:NO];
}
}
}
瞧