IDMPhotoBrowser
IDMPhotoBrowser copied to clipboard
Customize toolbar items (both toolbars: topToolbar, toolbar)
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!
Hi, thanks for the awesome fork. :+1: This is just what I need. Do you think you can add it to Cocoapods please?
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.