Skip to content

šŸ“· 图片 || 视频 ęµč§ˆå™Ø(ęœ¬åœ°å’Œē½‘ē»œ) , UIViewController + CollectionView , å®Œē¾Žé€‚é… iPhone 仄及 iPad ,å±å¹•ę—‹č½¬åŠŸčƒ½ , 适配SDWebImage 5.0

master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

README.md

image

KNPhotoBrowser

äø­ę–‡ | English

most like photo or video browser of Wechat(TX) and Weibo(Sina) in China
if you get any function to add, just contact me by E-mail. Welcome to Star

image image image image image

Update content

  • photoBrowser has been coded by UIViewController
  • ready for iPhoneX态iPhoneXS态iPhoneXR态iPhoneXS_Max态iPhone12Mini态iPhone12态iPhonePro_Max
  • perfect adapt for rotate of the Screen , try it on the real device
  • panGesture to dismiss or cancel
  • prefetch image with API
  • locate and net GIF is ready use
  • video player is ready to use( locate and net video)
  • video swipe function is ready to use
  • video player contain autoplay API
  • video player add quick play API
  • custom control on the photoBrowser
  • custom is followed with photoBrowser to dismiss or show
  • all alert or toast will be down by delegate function

1.Function describe and Point

  • 1.depend SDWebImage(5.0), if need locate gif, depend SDWebImage(5.8.3)
  • 2.most like photoBrowser of Wechat and Weibo in China
  • 3.provide function which can delete and download image or video
  • 4.custom control as you wish

2.How to use

1.init KNPhotoBrowser, set params

// 1.make every control as an object, put it into an array
KNPhotoItems *items = [[KNPhotoItems alloc] init];
items.url = [urlArr[i] stringByReplacingOccurrencesOfString:@"thumbnail" withString:@"bmiddle"];
items.sourceView = imageView;
// if current url is video type
// items.isVideo = true;
// if current image is locate gif
// itemM.isLocateGif = true;
[self.itemsArr addObject:items];

2.present , custom control as you wish

KNPhotoBrowser *photoBrowser = [[KNPhotoBrowser alloc] init];
photoBrowser.itemsArr = [self.itemsArr copy];
photoBrowser.isNeedPageNumView = true;
photoBrowser.isNeedRightTopBtn = true;
photoBrowser.isNeedPictureLongPress = true;
photoBrowser.isNeedPanGesture = true;
photoBrowser.isNeedPrefetch = true;
photoBrowser.isNeedAutoPlay = true;
photoBrowser.currentIndex = tap.view.tag;
photoBrowser.delegate = self;
[photoBrowser present];

3.provide Delegate --> KNPhotoBrowserDelegate

@optional
/**
 photoBrowser will dismiss
 */
- (void)photoBrowserWillDismiss;

@optional
/**
 photoBrowser right top button did click
 */
- (void)photoBrowserRightOperationAction;

@optional
/**
 photoBrowser Delete image success with relative index
 
 @param index relative index
 */
- (void)photoBrowserRightOperationDeleteImageSuccessWithRelativeIndex:(NSInteger)index;

@optional
/**
 photoBrowser Delete image success with absolute index
 
 @param index absolute index
 */
- (void)photoBrowserRightOperationDeleteImageSuccessWithAbsoluteIndex:(NSInteger)index;

@optional
/**
 is success or not of save picture
 
 @param success is success
 */
- (void)photoBrowserWriteToSavedPhotosAlbumStatus:(BOOL)success DEPRECATED_MSG_ATTRIBUTE("use delegate function photoBrowserToast:photoBrower:photoItemRelative:photoItemAbsolute:  instead");

@optional
/**
 download video with progress
 @param progress current progress
 */
- (void)photoBrowserDownloadVideoWithProgress:(CGFloat)progress;

@optional
/**
 photoBrowser scroll to current index
 @param index current index
 */
- (void)photoBrowserScrollToLocateWithIndex:(NSInteger)index;

@optional
/// photoBrowser did long press
/// @param photoBrowser photobrowser
/// @param longPress long press gestureRecognizer
- (void)photoBrowser:(KNPhotoBrowser *)photoBrowser longPress:(UILongPressGestureRecognizer *)longPress;

@optional
/// download image or video  success | failure | failure reason call back
/// @param photoBrowser toast on photoBrower.view
/// @param state state
/// @param photoItemRe relative photoItem
/// @param photoItemAb absolute photoItem
- (void)photoBrowser:(KNPhotoBrowser *)photoBrowser
               state:(KNPhotoShowState)state
   photoItemRelative:(KNPhotoItems *)photoItemRe
   photoItemAbsolute:(KNPhotoItems *)photoItemAb;

@optional
/**
 photoBrowser will layout subviews
 */
- (void)photoBrowserWillLayoutSubviews;

4.provide function of dismiss

// maybe you never use it
[_photoBrowser dismiss];

5.API

/**
 current select index
 */
@property (nonatomic,assign) NSInteger  currentIndex;

/**
 contain KNPhotoItems : url && UIView
 */
@property (nonatomic,strong) NSArray<KNPhotoItems *> *itemsArr;

/**
 Delegate
 */
@property (nonatomic,weak  ) id<KNPhotoBrowserDelegate> delegate;

/**
 is or not need pageNumView , default is false
 */
@property (nonatomic,assign) BOOL  isNeedPageNumView;

/**
 is or not need pageControl , default is false (but if photobrowser contain video,then hidden)
 */
@property (nonatomic,assign) BOOL  isNeedPageControl;

/**
 is or not need RightTopBtn , default is false
 */
@property (nonatomic,assign) BOOL  isNeedRightTopBtn;

/**
 is or not need PictureLongPress , default is false
 */
@property (nonatomic,assign) BOOL  isNeedPictureLongPress;

/**
 is or not need prefetch image, maxCount is 8 (KNPhotoBrowserPch.h)
 */
@property (nonatomic,assign) BOOL  isNeedPrefetch;

/**
 is or not need pan Gesture, default is false
 */
@property (nonatomic,assign) BOOL  isNeedPanGesture;

/**
 is or not need auto play video, default is false
 */
@property (nonatomic,assign) BOOL isNeedAutoPlay;

/**
 is or not need follow photoBrowser , default is false
 when touch photoBrowser, the customView will be hidden
 when you cancel, the customView will be showed
 when dismiss the photoBrowser immediately, the customView will be hidden immediately
 */
@property (nonatomic,assign) BOOL isNeedFollowAnimated;

/**
 delete current photo or video
 */
- (void)deletePhotoAndVideo;

/**
 download photo or video to Album, but it must be authed at first
 */
- (void)downloadPhotoAndVideo;

/**
 player's rate immediately to use
 */
- (void)setImmediatelyPlayerRate:(CGFloat)rate;

/**
create custom view on the topView(photoBrowser controller's view)
for example: create a scrollView on the photoBrowser controller's view, when photoBrowser has scrolled , you can use delegate's function to do something you think
delegate's function: 'photoBrowserScrollToLocateWithIndex:(NSInteger)index'
'CustomViewController' in Demo, you can see it how to use
@param customViewArr customViewArr
@param animated need animated or not, with photoBrowser present
@param followAnimated need animated or not for follow photoBrowser
*/
- (void)createCustomViewArrOnTopView:(NSArray<UIView *> *)customViewArr
                            animated:(BOOL)animated
                      followAnimated:(BOOL)followAnimated;

/**
 photoBrowser show
 */
- (void)present;

/**
 photoBrowser dismiss
 */
- (void)dismiss;

How to install

pod 'KNPhotoBrowser'

// terminal : cd ~(current path)
pod install or pod update

By the way

  • 1.Currently, It just be used in nine picure ,scrollView, tableView , chat session for IM
  • 2.if you find any bug, just contact me, it will be perfect by each other
  • 3.perfect adapt iPhone iPad
  • 4.perfect adapt the rotate of the Screen like Wechat and Weibo
  • 5.if you get any idea, just contact me! Thanks

About

šŸ“· 图片 || 视频 ęµč§ˆå™Ø(ęœ¬åœ°å’Œē½‘ē»œ) , UIViewController + CollectionView , å®Œē¾Žé€‚é… iPhone 仄及 iPad ,å±å¹•ę—‹č½¬åŠŸčƒ½ , 适配SDWebImage 5.0

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.