0

I want to make an iphone app like the native iphone photo gallery....i found a project MWPhotoBrowser and now i want to use some feature of this project....but i don't know how to do this....i am new in iphone apps development..

3 Answers3

5

First, you have to import in your project the "framework" you had downloaded. Then, you have to make a class "viewController" (the .h and .m files) and set the view like this: .h should be like this

#import <UIKit/UIKit.h>
#import "MWPhotoBrowser.h"

@interface PhotoLoader : UIViewController<MWPhotoBrowserDelegate> {
    NSArray *_photos;
    UISegmentedControl *_segmentedControl;
}
@property (nonatomic, retain) NSArray *photos;
@end

the file. m shoud be like this

//  PhotoLoader.m


#import "PhotoLoader.h"

@interface PhotoLoader ()

@end

@implementation PhotoLoader
@synthesize photos = _photos;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Create browser
    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
    browser.displayActionButton = YES;

    //show your photo whit url

    [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://Url.Photo.Here.jpg"]]];
    [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://http://Url.Photo.Here.jpg"]]];
    [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://http://Url.Photo.Here.jpg"]]];
    [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:@"http://http://Url.Photo.Here.jpg"]]];
    // Do any additional setup after loading the view.
}
- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return _photos.count;
}
- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    if (index < _photos.count)
        return [_photos objectAtIndex:index];
    return nil;
}
- (void)segmentChange {
    [self.tableView reloadData];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

That's all.

ЯegDwight
  • 24,821
  • 10
  • 45
  • 52
cyber91
  • 51
  • 1
  • 1
    Hello Mamunur. Please consider to set the checkmark at the answer if this is the right answer. This will help follow up readers. – brainray Oct 05 '12 at 11:54
2

Please refer there Github and also have look at DOC. This might be helpful. There are other Lib which can also help. All of them are following same steps of zooming, scrolling, cache, etc.

Community
  • 1
  • 1
HDdeveloper
  • 4,396
  • 6
  • 40
  • 65
2

The github page worked great for me. They have a great tutorial. Here is the link: https://github.com/mwaterfall/MWPhotoBrowser

Joe Phillips
  • 49,743
  • 32
  • 103
  • 159