PhotoBrowser
Support Storyboard using PBImageScrollView.
PhotoBrowser เป็นเบราว์เซอร์รูปภาพน้ำหนักเบา เช่น wechat, weibo โปรแกรมดูรูปภาพ
ขณะนี้มีเวอร์ชัน Swift บริสุทธิ์ชื่อ SlidePhoto แล้ว
UITableView
API เรามี DataSource
an Delegate
สำหรับโหลดข้อมูลและจัดการการดำเนินการPhotoBrowser
ว่าคุณต้องการนำเสนอกี่หน้าโดยปฏิบัติตามโปรโตคอล PBViewControllerDataSource
และใช้ numberOfPagesInViewController:
selectorpb_startPage
PBViewControllerDataSource
และใช้ viewController:imageForPageAtIndex:
selectorPBViewControllerDataSource
และใช้ตัวเลือก viewController:presentImageView:forPageAtIndex:progressHandler
PBViewControllerDataSource
และใช้ thumbViewForPageAtIndex:
บอกตำแหน่งเริ่มต้นและสิ้นสุด imageViewPBViewControllerDelegate
และใช้ viewController:didSingleTapedPageAtIndex:presentedImage:
หรือ viewController:didLongPressedPageAtIndex:presentedImage:
จัดการการแตะครั้งเดียวหรือการกดแบบยาว ...
PBViewController *pbViewController = [PBViewController new ];
// Use your own subclass of UIImageView to display.
pbViewController.imageViewClass = PBImageView.class;
pbViewController.pb_dataSource = self;
pbViewController.pb_delegate = self;
pbViewController.pb_startPage = sender.tag;
[ self presentViewController: pbViewController animated: YES completion: nil ];
...
...
# pragma mark - PBViewControllerDataSource
- ( NSInteger )numberOfPagesInViewController:(PBViewController *)viewController {
return self. frames . count ;
}
- ( void )viewController:(PBViewController *)viewController presentImageView:(UIImageView *)imageView forPageAtIndex:( NSInteger )index progressHandler:( void (^)( NSInteger , NSInteger ))progressHandler {
NSString *url = [ NSString stringWithFormat: @" https://raw.githubusercontent.com/cuzv/PhotoBrowser/dev/Example/Assets/ %@ .jpg " , @( index + 1 )];
UIImage *placeholder = self. imageViews [ index ]. image ;
[imageView sd_setImageWithURL: [ NSURL URLWithString: url]
placeholderImage: placeholder
options: 0
progress: progressHandler
completed: ^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
}];
}
- (UIView *)thumbViewForPageAtIndex:( NSInteger )index {
if (self. thumb ) {
return self. imageViews [ index ];
}
return nil ;
}
# pragma mark - PBViewControllerDelegate
- ( void )viewController:(PBViewController *)viewController didSingleTapedPageAtIndex:( NSInteger )index presentedImage:(UIImage *)presentedImage {
[ self dismissViewControllerAnimated: YES completion: nil ];
}
สำหรับข้อมูลเพิ่มเติม โปรดดูตัวอย่างในโครงการ
PhotoBrowser
มีให้บริการภายใต้ใบอนุญาต MIT ดูไฟล์ใบอนุญาตสำหรับข้อมูลเพิ่มเติม