Code Monkey home page Code Monkey logo

imageviewer.swift's Introduction

ImageViewer.swift

An easy to use Image Viewer that is inspired by Facebook

Version Deployment status License Platform

Screenshot-dark-modeScreenshot-light-mode Screenshot-auto-rotate

Supports

  • From iOS 10
  • Swift versions
    • Swift 4.0
    • Swift 4.2
    • Swift 5.0

Installation

CocoaPods

Using cocoapods

pod 'ImageViewer.swift', '~> 3.0'

If you need remote image fetching:

pod 'ImageViewer.swift', '~> 3.0'
pod 'ImageViewer.swift/Fetcher', '~> 3.0'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Alamofire into your Xcode project using Carthage, specify it in your Cartfile:

github "michaelhenry/ImageViewer.swift" ~> 3.2

How to use it

The simplest way to to use this is by using the imageView.setupImageViewer()

imageView.setupImageViewer()

Example:

import ImageViewer_swift

let imageView = UIImageView()
imageView.image = UIImage(named: 'cat1')
...
imageView.setupImageViewer()

Or you might load it from a URL

imageView.setupImageViewer(url: URL(string: "https://example.com/image.jpg")!)

Or you might load it with an array of images [UIImage]

let images = [
    UIImage(named: "cat1"),
    UIImage(named: "cat1"),
    UIImage(named: "cat1")
]
imageView.setupImageViewer(images: images)

Or you might load it with an array of URL [URL]

let urls = [
    URL(string: "https://example.com/your-image-1.jpg")!,
    URL(string: "https://example.com/your-image-2.jpg")!,
    URL(string: "https://example.com/your-image-3.jpg")!
]
imageView.setupImageViewer(urls: urls)

How to change the layout or options that are available

You can check this file ImageViewerOption.swift to see what are the available options that will fit to your needs.

public enum ImageViewerOption {
    case theme(ImageViewerTheme)
    case closeIcon(UIImage)
    case rightNavItemTitle(String, onTap: ((Int) -> Void)?)
    case rightNavItemIcon(UIImage, onTap: ((Int) -> Void)?)
}

You could also check the Demo Project for more information.

Easy peasy :)

Please let me know if you have any questions.

Cheers, Michael Henry Pantaleon

Twitter: @michaelhenry119

Linked in: ken119

http://www.iamkel.net

Dependency

License

MIT

Copyright (c) 2013 Michael Henry Pantaleon (http://www.iamkel.net). All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

imageviewer.swift's People

Contributors

abraaolevi avatar chaire avatar idevid avatar jangelsb avatar matsu911 avatar maziar avatar michaelhenry avatar minhhien177 avatar oscardemoya avatar tbergmen avatar thomasdao avatar thomasdelgado avatar uson1x avatar woxtu 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  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

imageviewer.swift's Issues

crash when swapping image

When I click on the image, the image is correctly zoomed and centered on the screen when if I try to move the image, a crash occurs

Orientation on iPad

Hello, thanks for your great component.
However, if I integrate on iPad, the landscape orientation is not supported. Can u support landscape orientation?

is this library dead?

There are no updates to it and too many bugs.

Anyone has an alternative to this lib?

Incompatible with iOS8 UIAlertController

I've tweaked the controller a bit so that a custom button would try to present a UIAlertController (new in the iOS8 SDK) on top of the MHFacebookImageViewer. This doesn't work because it's "Attempting to present on a view controller whose view is not in the window hierarchy!". Tried a couple of stuff but failed, not sure how to work around this.

how to disable gestures?

Great work! Quick question thought. I have a swipe down gesture recognizer already. I know i can add a tap recog on the imageview itself and disable it as soon as its touched, but when i swipe the imageview back to its imageframe how would i renable it?

Open and close blocks crash

I think that the open and close blocks should be strong and not weak:

@Property(nonatomic,strong) MHFacebookImageViewerOpeningBlock openingBlock;
@Property(nonatomic,strong) MHFacebookImageViewerClosingBlock closingBlock;

Otherwise it will crash if we do not store the blocks ourself.

License: What is the license for this?

Hello:

I would like to use this software in my app. But, it is problematic using a software with custom licenses. I have to send the license to a company attorney and wait until they give me a go ahead. Can you mention the license name and the version in your LICENSE file. A blessed license like MIT, Apache or BSD will make lives easy for the users of your library. Can you use one of the above licenses for your library?

Cocoapods support

Any plans to add this to Cocoapods? I might like to use this, but I'm already using Cocoapods for other libs and I'd like to keep it that way.

iOS 7 Compatibility

Doesn't seem to work too well with iOS 7. The background color is white and doesnt extend to fill the screen.
Swiping down to hide the image causes a crash.
Are there any plans to update it to make it iOs 7 compatible?

seperate image for popout view.

how would you go about having a higher quality image pop up upon tapping the imageview? I have two mutable dictionaries storing both hires and lowres thumbnail photos, respectively.

Open block run twice

When I open photo viewer by clicking on photo the open block runs twice because

  • (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath in MHFacebookImageViewer runs twice.
    So, how to fix it?

System Crash

I have encounter a problem. When I pressed "Done" button, and it jump to this thread.
movl (%edi), %esi

Moreover, this is not happen all the time.
So, is there any bug or something that can fix it?

Why ROTATE table and cell???

In MHFacebookImageViewer.m, why do you have this rotating back and forth??? LIke this...

_tableView.transform = CGAffineTransformMakeRotation(-M_PI_2);
_tableView.frame = CGRectMake(0,0,windowBounds.size.width,windowBounds.size.height);

...and this???

imageViewerCell.transform = CGAffineTransformMakeRotation(M_PI_2);

I commented those out and it seems to work just fine.

MHFacebookImageViewer + PKRevealController support

I have just started to develop an app using Xcode 5. When I call setupImageViewer, instead of getting the Image my actual view shrinks and gets a small border (like normally), but the _blackMask from MHFacebookImageViewer never shows up. I'm also using PKRevealController. Is there any way to use MHFacebookImageViewer using PKReveal?

Thanks in advance.

MHFacebookImageViewerCell: Sometimes __imageView has incorrect frame

fix:
In method [MHFacebookImageViewerCell setImageURL: defaultImage: imageIndex:] it needs to add following code.
...
if(_imageIndex==_initialIndex && !_isLoaded){
__imageView.frame = _originalFrameRelativeToScreen;
[UIView animateWithDuration:0.4f delay:0.0f options:0 animations:^{
__imageView.frame = [self centerFrameFromImage:__imageView.image];
CGAffineTransform transf = CGAffineTransformIdentity;
// Root View Controller - move backward
_rootViewController.view.transform = CGAffineTransformScale(transf, 0.95f, 0.95f);
// Root View Controller - move forward
// _viewController.view.transform = CGAffineTransformScale(transf, 1.05f, 1.05f);
_blackMask.alpha = 1;
} completion:^(BOOL finished) {
if (finished) {
_isAnimating = NO;
_isLoaded = YES;
if(_openingBlock)
_openingBlock();
}
}];

  •    } else {
    
  •        __imageView.frame = [self centerFrameFromImage:__imageView.image];
    }
    
    ...

iPhone X left space

I have fixed it by adding a function to the loadview (MHFacebookImageViewer)
if (@available(iOS 11, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}

Doesn't work with iPad in landscape orientation

The whole screen is rotated and shown in portrait mode. When the control returns, it leaves the whole app in wrong orientation.

It should not rotate the screen, just show it in the current orientation.

statusbar style

If i set up my status bar style in info.plist (ios7) the status bar is recovered to the wrong one , the default one.

any ideas how to fix it?

Open same Imageview on did select of UITableView

Hello Henry,

I have used this controller in my application and I am trying to open this UIImageview on UITableview didSelectRowAtIndexPath method. So Please suggest me if its possible to implement such a thing.

Thanks,

How to present another view controller

I tried to present a NavigationController in the class of MHFacebookImageViewerCell by
[self.viewController presentViewController:myNavigationController animated:YES completion:nil];

However the NavigationController presented behind the MHFacebookImageViewer instead of being on top.

Please help

Close button not always working

Hi Michael,

thanks for sharing this super nice code. In the demoproject the closebutton isn't always working (sometimes you have to press the closebutton multiple times before it closes). I see this behavior also on your video. Any clue what is going on? Or is it just me?

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.