Introduction
ZLPhotoBrowser-objc is a library written in Objective-C that provides a user-friendly way to display and browse photos in your iOS app. It offers features such as image zooming, sliding between images, and customizable UI elements. This documentation will guide you on how to use ZLPhotoBrowser-objc in your own projects.
Installation
To use ZLPhotoBrowser-objc in your project, you can either manually include the source files or install it via CocoaPods.
Manual Installation
- Download the latest version of ZLPhotoBrowser-objc from the GitHub repository.
-
Add the source files (
ZLPhotoBrowser
andZLPhotoActionSheet
) to your project.
Installation via CocoaPods
-
Add the following line to your Podfile:
pod 'ZLPhotoBrowser-objc'
-
Run
pod install
command in the terminal. -
Import the library using the import statement in your Swift file:
#import <ZLPhotoBrowser/ZLPhotoBrowser.h>
Usage
Initialization
To start using ZLPhotoBrowser-objc, you need to initialize an instance of ZLPhotoBrowser
.
// Swift
ZLPhotoBrowser *photoBrowser = [[ZLPhotoBrowser alloc] init];
// Objective-C
let photoBrowser = ZLPhotoBrowser()
Data Source
ZLPhotoBrowser-objc requires a data source to populate the images to be displayed. The data source should conform to the ZLPhotoBrowserDataSource
protocol and implement the required methods.
photoBrowser.dataSource = self;
- (NSInteger)numberOfPhotosInPhotoBrowser:(ZLPhotoBrowser *)photoBrowser {
return self.photos.count;
}
- (ZLPhotoModel *)photoBrowser:(ZLPhotoBrowser *)photoBrowser photoAtIndex:(NSInteger)index {
return self.photos[index];
}
Delegate
The ZLPhotoBrowserDelegate
protocol provides optional methods to handle events and customize the behavior of the photo browser.
photoBrowser.delegate = self;
Presentation
To present the photo browser, you can use the present
method or push it onto a navigation stack.
// Present modally
[self presentViewController:photoBrowser animated:YES completion:nil];
// Push onto navigation stack
[self.navigationController pushViewController:photoBrowser animated:YES];
More Information
For more information on how to use ZLPhotoBrowser-objc and its available features, please refer to the GitHub repository and the CocoaDocs documentation.