IDMPhotoBrowser icon indicating copy to clipboard operation
IDMPhotoBrowser copied to clipboard

Customize toolbar items (both toolbars: topToolbar, toolbar)

Open XBeg9 opened this issue 10 years ago • 2 comments

I have the same issue with MWPhotoBrowser. There is no way to add new button or something like that. I have added additional method to add toolbarItems and moved "Done" button into toolbar. In such controls it's better to give developer more flexibility. Also, I've updated example with "Customized Photo Browser" section. You can see two additional buttons on topToolbar and on bottomToolbar. Also suggestion to rename toolbar -> bottomToolbar. Thanks!

XBeg9 avatar Aug 06 '13 13:08 XBeg9

Hi, thanks for the awesome fork. :+1: This is just what I need. Do you think you can add it to Cocoapods please?

Isuru-Nanayakkara avatar Apr 02 '14 08:04 Isuru-Nanayakkara

There's a way to add custom buttons to a toolbar by extending the IDMPhotoBrowser:

//
//  IDMPhotoBrowserExtended.h

#import "IDMPhotoBrowser.h"

@interface IDMPhotoBrowser ()
{
    UIToolbar *_toolbar;
}

- (void) performLayout;

@end

@interface IDMPhotoBrowserExtended : IDMPhotoBrowser

@property (nonatomic, retain) NSMutableArray *items;

@end
//  IDMPhotoBrowserExtended.m

#import "IDMPhotoBrowserExtended.h"

@interface IDMPhotoBrowserExtended ()

@end

@implementation IDMPhotoBrowserExtended
@synthesize items = _items;

- (void)performLayout {
    [super performLayout];

    if (_items && _items.count > 0) {


        NSLog(@"Performing layout");
        UIToolbar *toolBar = [super valueForKey:@"_toolbar"];

        NSMutableArray *newItems = [toolBar.items mutableCopy];
        for (UIBarButtonItem *item in _items) {
            [newItems insertObject:item atIndex:newItems.count - 1];
        }
        [toolBar setItems:newItems];
    }
}

@end

Well, actual adding to array is a bit dirty but I had to add just a single item so didn't have time to make this perfect.

hryamzik avatar Jul 18 '14 17:07 hryamzik