我想制作一个像原生iphone照片库的iPhone应用程序....我发现了一个项目MWPhotoBrowser,现在我想使用这个项目的一些功能....但我不知道该怎么做....我是iphone应用程序开发的新手..
答案 0 :(得分:5)
首先,您必须在项目中导入已下载的“框架”。然后,你必须创建一个类“viewController”(.h和.m文件)并设置如下视图: .h应该是这样的
#import <UIKit/UIKit.h>
#import "MWPhotoBrowser.h"
@interface PhotoLoader : UIViewController<MWPhotoBrowserDelegate> {
NSArray *_photos;
UISegmentedControl *_segmentedControl;
}
@property (nonatomic, retain) NSArray *photos;
@end
文件。我应该是这样的
// 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
就是这样。
答案 1 :(得分:2)
答案 2 :(得分:2)
github页面对我很有用。他们有一个很棒的教程。这是链接:https://github.com/mwaterfall/MWPhotoBrowser