Ios 在选项卡式应用程序中从 UITableView 启动 Fgallery

发布于 2024-12-20 08:37:28 字数 2289 浏览 2 评论 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 的新手,我陷入了困境。

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

谢谢

I am trying to build a small app. It's a tabbed app with 3 tabs: photos, videos, documents
Each tab displays a tableview to select wich gallery, video, document is to be shown; Videos work fine.

I'm having trouble with photo galleries. I use Fgallery which is working fine from the sample: 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;
}

and

#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];
    ...
}

I really don't know how to display the gallery. The didSelectRowAtIndexPath is the one from fgallery, I tried to modify it to show the viewm but I'm new to Objective-C and I'm stuck.

Any help or guideline will be appreciated.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铃予 2024-12-27 08:37:28

我添加了

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

视图现在显示正常,但我缺少后退按钮

I added

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

View shows ok now but I am missing the back button

や三分注定 2024-12-27 08:37:28

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

,瞧

In FGalleryViewController.m, I added btn2 to the navigation controller

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

And voilà

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文