Git Product home page Git Product logo

lukane / knphotobrowser Goto Github PK

View Code? Open in Web Editor NEW
369.0 10.0 76.0 33.38 MB

图片浏览器(本地和网络) ,视频浏览器 (本地和网络), 无耦合性,自定义控件,资源路径保存和获取, 完美适配 iPhone 以及 iPad ,屏幕旋转功能.

License: MIT License

Objective-C 99.38% Ruby 0.27% C 0.35%
photobrowser ipad iphone uiviewcontroller video-player download loading rotate video pagecontrol

knphotobrowser's Introduction

image

CocoaPods CocoaPods Support 

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

imageimageimageimageimage

Update content

DESCRIPTION
Base on UIViewController
Adapt for rotate of the screen, split screen of iPad
Adapt for iPhone5~iPhone14Pro_Max
Locate and net image and gif image
Locate and net video
PageControl can add target to change value [API]
PanGesture to dismiss or cancel(normal image, long image, video) [API]
Prefetch image, max is 8 [API]
Video player auto play [API]
Video player times speed play [API]
Video player support play online(no cache,no download) [API]
Video player support play after download(it will search next time) [API]
Show custom view on PhotoBrowser [API]
Show custom view on PhotoBrowser, and set animated following photoBrowser [API]
Before the photoBrowser show, all image control can be custom [API]
All operation though the delegate [Delegate]
push ViewController (2022-12) [API]
reload collection dataSource (2022-12) [API]
load locate image with source path (2024-03) [API]

TODO:

  • tap video player to dismiss [Finished in demo]
  • play video player and download video background
  • video player has memory play at next time(current seconds)
  • when photoBrower will show or dismiss, let sourceImageView hidden or show (by delegate function to notificate demo) [Finished in demo]
  • video player change scale

1.Before use, you need to know

  • 1.depend >=SDWebImage(5.0), if need locate gif image, depend >=SDWebImage(5.8.3)
  • 2.image and video play is ready for use
  • 3.download image or video is ready for use
  • 4.custom control as you wish
  • 5.auto manager image or video of download is finished

2.How to use

(1).init base params

// 1.make every control as an object, put it into an array
KNPhotoItems *items = [[KNPhotoItems alloc] init];
items.url = @"http://xxxxxxxx/xxx.png";
items.sourceView = imageView;
// if current url is video type
// items.isVideo = true;
// if current image is locate gif
// itemM.isLocateGif = true;

// if current image is locate image with path url
// itemM.url = @"/xx/ssd/xxx/ss.png"
// itemM.

[self.itemsArr addObject:items];

(2).init PhotoBrowser

KNPhotoBrowser *photoBrowser = [[KNPhotoBrowser alloc] init];
photoBrowser.itemsArr = [self.itemsArr copy];
photoBrowser.currentIndex = tap.view.tag;

/// photoBrowser will present
[photoBrowser present];

/// photoBrowser will dismiss
/// [photoBrowser dismiss];

(3).function's describe of delegate

photoBrowser will dismiss
/// photoBrowser will dismiss with currentIndex
- (void)photoBrowser:(KNPhotoBrowser *)photoBrowser willDismissWithIndex:(NSInteger)index;
photoBrowser right button did click
/// photoBrowser right top button did click with currentIndex (you can custom you right button, but if you custom your right button, that you need implementate your target action)
- (void)photoBrowser:(KNPhotoBrowser *)photoBrowser rightBtnOperationActionWithIndex:(NSInteger)index;

.....

(4).component of browser : KNPhotoItems

base params of items
/// if it is network image,  set `url` , do not set `sourceImage`
@property (nonatomic,copy  ) NSString *url;

/// if it is locate image, set `sourceImage`, do not set `url`
@property (nonatomic,strong) UIImage *sourceImage;

/// sourceView is current control to show image or video.
/// 1. if the sourceView is kind of `UIImageView` or `UIButton` , just only only only set the `sourceView`.
/// 2. if the sourceView is the custom view , set the `sourceView`, but do not forget set `sourceLinkArr` && `sourceLinkProperyName`.
@property (nonatomic,strong) UIView *sourceView;
custom source View (it is very nice)
@property (nonatomic,strong) NSArray<NSString *> *sourceLinkArr;

/**
 eg:
    if the lastObject is kind of  UIImageView ,  the `sourceLinkProperyName` is `image`
    if the lastObject is kind of  UIButton ,  the `sourceLinkProperyName` is `currentBackgroundImage` or `currentImage`
 */

/// the property'name of the  sourceLinkArr lastObject
@property (nonatomic,copy  ) NSString *sourceLinkProperyName;

3.How to install

pod 'KNPhotoBrowser'

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

5.By the way

  • if you get any idea, just contact me! Thanks

knphotobrowser's People

Contributors

hstdt avatar lukane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knphotobrowser's Issues

翻页严重卡顿

在- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath 方法中,
UIImageView *tempView = [self tempViewFromSourceViewWithCurrentIndex:indexPath.row];会导致翻页的时候卡顿

优化

调用downloadPhotoAndVideo方法,http地址时每次都是要重新下载,可不可以支持只下载一次,再次调用时无需重新下载

关于依赖的建议

能不能把依赖三方的版本号去掉,或者使用其他标识符,现在你这个依赖会和项目依赖有版本冲突。
还有 FLAnimatedImage 这个库我相信许多项目都会依赖,而你直接复制文件到你的项目,这个很容易引起依赖你这个组建的项目编译错误

优化

可不可以支持播放一次后,再次播放的时候直接从沙盒中去取资源本地播放,现在是每次播放都是进行的网络播放。

图片contentMode未设置

demo中九宫格图片显示没有设置图片的contentMode, 一般情况下都会设置UIViewContentModeScaleAspectFill并裁剪,但是在显示预览的时候[tempView setContentMode:sourceView.contentMode];为啥被注释了呢,然后在dismiss的时候 也应该设置[tempView setContentMode:items.sourceView.contentMode];

collectionview问题

你好,我想问一下collectionview两个item之间的间距是怎么设置的

iOS 10.0以上BUG

突然发现iOS 10.0以上放大图片,划动到下一个图片,前面放大的图片没有变回原来的大小

预览的数组中只有一个视频的时候,左滑闪退

使用demo OR 最新的pod库 当只有一个网络视频预览时,左滑会闪退,
当只有一个视频时,uicollectionview是不能滚动的,这个时候会走到 panDidGesture 方法里面,会调用到 '-[KNPhotoAVPlayerView playerWillSwipeCancel]: 导致闪退

视频预览

视频预览,拖拽时快速晃动,会出现两个view错位出来

网络视频

网络视频不设置 isNeedOnlinePlay 相当于默认下载完再播放,播放器黑屏

视频预览

视频预览,视频播放结束一次后,拖拽变小后再拖动回去,播放按钮不见了

iOS 13 "statusBar" crash问题

UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"statusBar"];
在iOS 13会导致crash,需要做适配处理,处理方法可供参考

if (@available(iOS 13.0, *))
{
    UIWindow *statusBar = [UIApplication sharedApplication].keyWindow;

    UIView *statusView = [[UIView alloc]initWithFrame:statusBar.windowScene.statusBarManager.statusBarFrame];
            
    [UIView animateWithDuration:0.15 animations:^{
        statusView.transform = CGAffineTransformIdentity;
    }];
}
else
{
    UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"statusBar"];
    
    [UIView animateWithDuration:0.15 animations:^{
        statusBar.transform = CGAffineTransformIdentity;
    }];
}

消失的位置

请把消失的位置 用 delegate 返回来呗
有时候可以处理一些 围绕 位置 的事件

图片打开问题

1、打开第二张图片的时候总会先显示第一张图片,然后再变成第二张;
2、关闭预览的时候,总是会回到第一张图片的位置

图片显示有问题

图片

[pauseImgView setImage:[UIImage imageNamed:@"KNPhotoBrowser.bundle/[email protected]"]]; 这里应该是: [pauseImgView setImage:[UIImage imageNamed:@"KNPhotoBrowser.bundle/playCenter"]]; 不然适配不了3@x 图

图片异常

我的sourseview设置了UIViewContentModeScaleAspectFit,浏览器消失的时候,图片异常

无法pod导入

warning: Could not find remote branch 2.0 to clone.
fatal: Remote branch 2.0 not found in upstream origin
请问这是什么原因呢

怎么使用复用

这个框架好用,现在我也遇到复用问题,点击的时候复用cell,我下面两句代码没写,是不是这个原因。然后还有就是,我的collectionView 分了两组我写了下面的后 报错-[UIView image]: unrecognized selector sent to instance 0x1557c0cb0
[photoBrower setDataSourceUrlArr:[self.collectionPrepareArr copy]];
[photoBrower setSourceViewForCellReusable:_collectionView];

这个我该怎么解决的呀,希望大神你能看到,给个建议

present可能导致无法正确展示

- (void)present{
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window.rootViewController presentViewController:self animated:false completion:^{
        
    }];
}

如果 A -> B -> photoBrowser, 如果A -> B是通过present方式跳转的(full screen), 那么在B页面查看view hierarchy, 发现里边内容是[window, B], 并没有A. 于是这里使用keyWindow的rootViewController也就是A去进行present, 就会无反应并提示:

We couldn’t find any repositories matching 'Attempt to present <KNPhotoBrowser: 0x11216ce00> on <RootViewController: 0x112834c00> whose view is not in the window hierarchy!'

我直接用[B presentViewController:photoBrower animated:YES completion:nil];进行展示躲过这个问题.

视频

视频预览dismiss的时候图片会扭曲一下

也是图片显示问题

和上个同学遇到一样的问题,他是ViewController控制器,我这是在CollectionView控制器,你原来是10张图片,一个界面就展示全了,没有cell重用,我自己又添加了几张图片让cell实现重用,进入collectionVIew页面之后,一开始什么都正常,点哪张从哪张位置放大,可以滚动缩放,单击缩小并返回原来的位置,可是当我将collectionView拉倒底部再回滚到顶部的时候,点击重用的cell显示图片就是乱的,比如说点的第三个cell,图片从第二个位置开始放大,最终显示的图片是对的,缩小回去的时候回到的也是第二个cell的位置,另外也不是每张图片都变成这样,有的是正常的,有的就会出现上面的问题。
PS:最近在做的工程有类似相册展示的功能,看到作者的demo很给力就想复用一下,途中遇到一点问题,描述的比较冗余,如果作者能看到,希望帮忙解答一下,万分感谢!

视频播放页左滑时闪退

NSInvalidArgumentException: -[KNPhotoAVPlayerView playerWillSwipeCancel]: unrecognized selector sent to instance 0x103510710

使用新版SDWebImage下载图不会显示圆形进度条

首先感谢作者无私奉献源码, 在使用新版SDWebImage下载图不会显示圆形进度条,我使用的是新版SDWebImage4.0, 在下载图片的时候不会显示进度, 换成你项目中的SDWebImage版本就可以, 不知道是我用法错了还是什么原因, 希望作者回复.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.