+ (instancetype)itemWithURL:(NSString *)URLString thumbnailURL:(NSString*)thumbnailURL; //Thumbs are automatically generated for Videos. But you can set Thumb Images for GalleryTypeImage.
+ (instancetype)itemWithURL:(NSString*)URLString galleryType:(MHGalleryType)galleryType;
+ (instancetype)itemWithYoutubeVideoID:(NSString*)ID;
+ (instancetype)itemWithVimeoVideoID:(NSString*)ID;
+ (instancetype)itemWithImage:(UIImage*)image;
MHGalleryController
+(instancetype)galleryWithPresentationStyle:(MHGalleryViewMode)presentationStyle;
@property (nonatomic,assign) id<MHGalleryDelegate> galleryDelegate;
@property (nonatomic,assign) id<MHGalleryDataSource> dataSource;
@property (nonatomic,assign) BOOL autoplayVideos; //Default NO
@property (nonatomic,assign) NSInteger presentationIndex; //From which index you want to present the Gallery.
@property (nonatomic,strong) UIImageView *presentingFromImageView;
@property (nonatomic,strong) MHGalleryImageViewerViewController *imageViewerViewController;
@property (nonatomic,strong) MHOverviewController *overViewViewController;
@property (nonatomic,strong) NSArray *galleryItems; //You can set an Array of GalleryItems or you can use the dataSource.
@property (nonatomic,strong) MHTransitionCustomization *transitionCustomization; //Use transitionCustomization to Customize the GalleryControllers transitions
@property (nonatomic,strong) MHUICustomization *UICustomization; //Use UICustomization to Customize the GalleryControllers UI
@property (nonatomic,strong) MHTransitionPresentMHGallery *interactivePresentationTransition;
@property (nonatomic,assign) MHGalleryViewMode presentationStyle;
@property (nonatomic,assign) UIStatusBarStyle preferredStatusBarStyleMH;
@property (nonatomic, copy) void (^finishedCallback)(NSUInteger currentIndex,UIImage *image,MHTransitionDismissMHGallery *interactiveTransition,MHGalleryViewMode viewMode);
I try to display an image with your gallery but i always have this error :
-[UIImageView setImageForMHGalleryItem:imageType:successBlock:]: unrecognized selector sent to instance
When scrolling through an album of imgur images, the gallery often crashes my app with this error. No idea why. Example album: http://imgur.com/a/whl0p
I'm using AFNetworking and MHVideoPhotoGallery on my project, importing "UIImageView+AFNetworking.h" and "MHGallery.h" (UIImageView+WebCache.h) in the same file and both has the method:
When I pass a very long text (e.g. a photo description from Facebook) it would be really great, if only the first lines are visible and the user can scroll up to fully read the description.
Facebook does the same with Facebook Paper
It seems that since Xcode 6 beta 4 assigning to the description property of MHGalleryItem causes crashes. This is because NSObject implements a method description, which is used for other purposes and you are trying to override this with a property.
Renaming the property fixes the issue.
When rotating the image view to landscape, swiping to dismiss causes the image viewer to revert to portrait, but then nothing occurs. Performing a second swipe successfully dismisses the image. If you select the same image again the image viewer is displayed in landscape but the layout is a little off. Occurs on both iPhone and iPad.
I'm encountering strange problem with some videos, from Youtube for now. First off the video thumbnail is not displayed, only grey background. After press video starts to load but it will not starts playing until play is pressed.
When the button Done is pressed, thats when the crash occurs with following:
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
I don't have the "why" of the crash (yet) but I can reproduce it.
The crash happens after trying to play this (240p only) video: https://www.youtube.com/watch?v=sn_GCGJCxo8
After waiting a few seconds the video doesn't seem to load even though the time bar appears. If you try to dismiss the video at this point the app crash at line 183 of MHTransitionDismissMHGallery.m with Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
Line 183 of MHTransitionDismissMHGallery.m is the last line of the following portion of code
if (imageViewerCurrent.isPlayingVideo && imageViewerCurrent.moviePlayer) {
self.moviePlayer = imageViewerCurrent.moviePlayer;
[self.moviePlayer.view setFrame:AVMakeRectWithAspectRatioInsideRect(imageViewerCurrent.moviePlayer.naturalSize,fromViewController.view.bounds)];
imageViewerCurrent.moviePlayer.naturalSize has a value of {0,0} in this situation, causing the exception.
MHVideoPhotoGallery causes issue with the status bar of the presenting controller. The two main issues I'm having:
It doesn't take into account if the status bar is already hidden. If the status bar is hidden in the presenting controller, MHVideoPhotoGallery makes it appear again (with the side effect of overlapping the navigation bar on the first image).
Because of 1., when MHVideoPhotoGallery is dismissed, the status bar is now visible. The only way to hide it is to first set it to visible, then to hidden again in the dismiss block, but this causes an unwanted visible effect.
If the original status bar color was light, the color gets set to default. Similar to 2, setting it back in the dismiss block causes an unwanted visible effect.
I think if the status bar is already hidden, the MHVideoPhotoGallery should also keep it hidden. Also, it should either a) restore the status bar to the original state before the dismiss block is called, or provide a willDismiss callback that allows the user to set things back before MHVideoPhotoGallery is dismissed to prevent the visible effects.
How can I Disable collection gallery in this lib?
I mean this collection: I tap on photo and I am in photoView, I tap back and I am in collection gallery.
I want to go back to my VC then I tap this back. Is it possible?
Undefined symbols for architecture i386:
"_AVMakeRectWithAspectRatioInsideRect", referenced from:
-[MHTransitionShowOverView animateTransition:] in MHTransitionShowOverView.o
-[MHTransitionShowOverView startInteractiveTransition:] in MHTransitionShowOverView.o
-[MHTransitionShowShareView animateTransition:] in MHTransitionShowShareView.o
-[MHTransitionDismissMHGallery animateTransition:] in MHTransitionDismissMHGallery.o
-[MHTransitionDismissMHGallery startInteractiveTransition:] in MHTransitionDismissMHGallery.o
-[MHImageViewController centerImageView] in MHGalleryImageViewerViewController.o
"_CMTimeGetSeconds", referenced from:
___54-[MHGallerySharedManager createThumbURL:successBlock:]_block_invoke in MHGallerySharedManager.o
"_CMTimeMakeWithSeconds", referenced from:
___54-[MHGallerySharedManager createThumbURL:successBlock:]_block_invoke in MHGallerySharedManager.o
"_MPMoviePlayerLoadStateDidChangeNotification", referenced from:
-[MHImageViewController removeAllMoviePlayerViewsAndNotifications] in MHGalleryImageViewerViewController.o
-[MHImageViewController addMoviePlayerToViewWithURL:] in MHGalleryImageViewerViewController.o
"_MPMoviePlayerPlaybackDidFinishNotification", referenced from:
-[MHImageViewController removeAllMoviePlayerViewsAndNotifications] in MHGalleryImageViewerViewController.o
-[MHImageViewController addMoviePlayerToViewWithURL:] in MHGalleryImageViewerViewController.o
"_MPMoviePlayerPlaybackStateDidChangeNotification", referenced from:
-[MHImageViewController removeAllMoviePlayerViewsAndNotifications] in MHGalleryImageViewerViewController.o
"OBJC_CLASS$_AVAssetImageGenerator", referenced from:
objc-class-ref in MHGallerySharedManager.o
"OBJC_CLASS$_AVURLAsset", referenced from:
objc-class-ref in MHGallerySharedManager.o
"OBJC_CLASS$_MPMoviePlayerController", referenced from:
objc-class-ref in MHGalleryImageViewerViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I updated from version 1.4 to 1.5 with no changes to my code, and now when I tap on an image to present it in MHVideoPhotoGallery, the image no longer appears. If I try and dismiss that view, it produces the below crash.
I noticed that if I log the description of an MHGalleryItem object created with initWithImage it shows "nil description". This is the case for both version 1.4 and 1.5. In version 1.4, however, if I add those images as MHGalleryController galleryItems, it still works fine.
Currently when you present the gallery controller it displays the image with the navigation bar and toolbar visible, then tapping on the image hides them. Is it possible to display the image with the bars hidden from the beginning, then tapping the image makes them visible again?
Hi, i'm creating a new app and I found this library fantastic.
However I noticed an incoming problem with iOS 8: By using a custom share interface (which is a great clone of photos app) we can't access the share extensions 3rd apps are going to provide.
One solution consists in replacing the actual ui, by just a multiple image picker (current is fine) and after selection is done, launch the iOS8 UIActivityViewController.
Another solution is just adding a button to the current custom ui to launch the UIActivityViewController in case the user want to use an extension.
Both solutions result in a 2-step sharing process which results in a poor user experience.
Hello
first i want to congratulate you for this excellent piece of work. the coding is excellent.
I only found 1 issue so far.
if you go first to 1st tab," CollectionInTable", and select the first image on the first cell and tap on the share icon you will see the image to share correctly.
Now tap cancel and go back to the local view tab. Select an album and then an image.Tap share. Instead of the image i see a grey exclamation mark.
i checked the code and the error coming from the SDWebimage is :
Error Domain=NSURLErrorDomain Code=-1100 "The operation couldn’t be completed. (NSURLErrorDomain error -1100.)"
if when you first open the app you go directly to the local tab and select an album and an image then the sharing works fine and the image looks ok.
in order to reproduce the error you must first tap share on an image inside the 1st tab, and then go back to the 4th local tab to do that again.
again thanks so much for this library.
Regards
Konstantinos
The issue is reproducible with the demo project, on a device or the simulator running iOS 8:
Open the gallery by touching an image or video
Start a swipe gesture to dismiss the gallery
Reverse your gesture to prevent the dismissing to happen
The result is the "closure" of the gallery (and the impossibility to re-open another one, seems like the gallery view controller is still presented somehow).
The expected behavior is the cancellation of the dismissing.
Ok, thanks to this post here's a (temporary?) solution:
Add
if ([self.context respondsToSelector:@selector(viewForKey:)]) { // is on iOS 8
[[UIApplication sharedApplication].keyWindow addSubview:fromViewController.view];
}
Beware the completion block of the dismiss call on the gallery view controller is always called, even if the dismiss is canceled! (In iOS 7 this completion block was called only in the case of a successful dismiss of the viewController).
Must have at least 2 images/videos open in MHGalleryImageViewerViewController
scroll to the last but one image/video
push share button
scroll to last image/video in the MHShareViewController
Press Cancel
the share view controller will dismiss and the last image/video will be presented in MHGalleryImageViewerViewController
ISSUE: the rightBarButton which switches to the next image/video is enabled and when it is pressed the application crashes because * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
Exception happens in MHGalleryController.itemForIndex:
Bug can be fixed with placing the below code to the end of MHGalleryImageViewerViewController.viewWillAppear
There is an issue when using an ActivityViewController instead of an MHShareView on iOS 8; it requires an anchor point to be specified or the app will crash otherwise.
My fork is a mess and I am not sure how to create a pull request for only one commit but the fix is really short: c701a07
On iOS7.1 The presenting animation is performing weirdly and exiting gallery by tapping "Done" (MOstly when you're on a index with video on it) it crashes.
Hello, How can I use your 'OverView interactive (dismiss & present)' with gallery.UICustomization.showOverView = NO; ?
I mean with image view not running MHVideoPhotoGallery
All the places in the project (other than the parts from SDWebImage) where "__block" appears in the code, it is completely unnecessary. In all the places, the __block variable is not assigned to anywhere after definition. And in some places, it even looks like it was used for a weak reference from pre-ARC days, which is no longer correct in ARC because __block in ARC is still by default a strong reference.
2 x blockSelf in MHGalleryImageViewerViewController.m:396 and 416: "blockSelf" never assigned to after definition, and in fact is always the same as "self" since "self" is never assigned to either.
quality in MHGallerySharedManager.m:361: "quality" never assigned to after the initial if-statement.
completionHandler in MHShareViewController.m:602: "completionHandler" never assigned to after definition, and is not even captured by a block.
blockSession in MHShareViewController.m:803: "blockSession" never assigned to after definition, and in fact is always the same as "session" since "session" is never assigned to after definition either.
2 x pageIndex in MHTransitionDismissMHGallery.m:44 and 146: "pageIndex" not even used in a block.
blockGallery in ExampleViewControllerCollectionViewInTableView.m:241: "blockGallery" never assigned to after definition, and in fact is always the same as "gallery" since "gallery" is never assigned to after definition either.
blockSelf in ExampleViewControllerImageView.m:67: "blockSelf" never assigned to after definition, and in fact is always the same as "self" since "self" is never assigned to either.
blockGallery in ExampleViewControllerLocal.m:110: "blockGallery" never assigned to after definition, and in fact is always the same as "gallery" since "gallery" is never assigned to after definition either.
blockGallery in ExampleViewControllerTableView.m:112: "blockGallery" never assigned to after definition, and in fact is always the same as "gallery" since "gallery" is never assigned to after definition either.
Hey,
thanks for sharing your work. I really like it.
The dataSource for a gallery always contains MHGalleryItems which rely on the url. My dataSource (NSMutableArray) is made up of several UIImages fetched by CoreData objects. Is it possible to extend "MHGalleryItem" to support direct use of UIImages? Or do I need to write them down to the filesystem in order to get the url?