0

我正在尝试构建一个小应用程序。这是一个带有 3 个选项卡的选项卡式应用程序:照片、视频、文档每个选项卡显示一个表格视图以选择要显示的画廊、视频、文档;视频工作正常。

我在使用照片库时遇到了问题。我使用Fgallery从示例中可以正常工作:Fgallery git

。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 的新手,我被卡住了。

任何帮助或指导将不胜感激。

谢谢

4

2 回答 2

0

我添加了

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

现在查看显示正常,但我缺少后退按钮

于 2011-12-11T19:33:32.437 回答
0

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

于 2011-12-11T23:02:52.257 回答