kevin-lyn / stpopuppreview Goto Github PK
View Code? Open in Web Editor NEWAn alternative peek preview for non 3D Touch devices. Inspired by Instagram.
License: MIT License
An alternative peek preview for non 3D Touch devices. Inspired by Instagram.
License: MIT License
ld: library not found for -lSTPopup
I am facing an erro using STPopupPreviedw with MXSegmentedPager
Actually, I have no idea this problem is related to MXSegmentedPager
In the blurred background view, the frame is incorrect
To see the error, please, see the video demo
- (UIViewController *)previewViewControllerForPopupPreviewRecognizer:(STPopupPreviewRecognizer *)popupPreviewRecognizer{
if (![popupPreviewRecognizer.view isKindOfClass:[CellFuturePost_CollectionViewCell class]]) {
return nil;
}
CellFuturePost_CollectionViewCell *cell = popupPreviewRecognizer.view;
PreviewViewController *previewViewController = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([PreviewViewController class])];
previewViewController.post = cell.post;
return previewViewController;
}
- (UIViewController *)presentingViewControllerForPopupPreviewRecognizer:(STPopupPreviewRecognizer *)popupPreviewRecognizer{
return self;
}
- (NSArray<STPopupPreviewAction *> *)previewActionsForPopupPreviewRecognizer:(STPopupPreviewRecognizer *)popupPreviewRecognizer{
if (![popupPreviewRecognizer.view isKindOfClass:[CellFuturePost_CollectionViewCell class]]) {
return nil;
}
CellFuturePost_CollectionViewCell *cell = popupPreviewRecognizer.view;
STPopupPreviewAction * seePost = [STPopupPreviewAction actionWithTitle:@"Ver post" style:STPopupPreviewActionStyleDefault handler:^(STPopupPreviewAction *action, UIViewController *previewViewController) {
[self.delegate openPost:cell.post];
}];
STPopupPreviewAction * like = [STPopupPreviewAction actionWithTitle:@"Like" style:STPopupPreviewActionStyleDefault handler:^(STPopupPreviewAction *action, UIViewController *previewViewController) {
[self.delegate openLikes:cell.post];
}];
STPopupPreviewAction * comment = [STPopupPreviewAction actionWithTitle:@"Comment" style:STPopupPreviewActionStyleDefault handler:^(STPopupPreviewAction *action, UIViewController *previewViewController) {
[self.delegate openComment:cell.post];
}];
return @[seePost, like, comment];
}
// // ProfileViewController.h #import <UIKit/UIKit.h> #import <MBProgressHUD.h> #import <SDWebImage/UIImageView+WebCache.h> #import <STPopup/STPopup.h> @interface ProfileViewController : UIViewController<STPopupControllerTransitioning> @end
`
#import "ProfileViewController.h"
@interface ProfileViewController ()
@implementation ProfileViewController
}
-(void)updateUserContactDetails:(NSString *)path Params:(NSDictionary *)params{
STPopupController *popupController = [[STPopupController alloc] initWithRootViewController:[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"MobileUpdateOTP"]];
popupController.style = STPopupStyleBottomSheet;
[popupController presentInViewController:self];
}
#pragma mark - STPopupControllerTransitioning
(NSTimeInterval)popupControllerTransitionDuration:(STPopupControllerTransitioningContext *)context
{
return context.action == STPopupControllerTransitioningActionPresent ? 0.5 : 0.35;
}
(void)popupControllerAnimateTransition:(STPopupControllerTransitioningContext *)context completion:(void (^)())completion
{
UIView *containerView = context.containerView;
if (context.action == STPopupControllerTransitioningActionPresent) {
containerView.transform = CGAffineTransformMakeTranslation(containerView.superview.bounds.size.width - containerView.frame.origin.x, 0);
[UIView animateWithDuration:[self popupControllerTransitionDuration:context] delay:0 usingSpringWithDamping:1 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
context.containerView.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished) {
completion();
}];
}
else {
[UIView animateWithDuration:[self popupControllerTransitionDuration:context] delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
containerView.transform = CGAffineTransformMakeTranslation(- 2 * (containerView.superview.bounds.size.width - containerView.frame.origin.x), 0);
} completion:^(BOOL finished) {
containerView.transform = CGAffineTransformIdentity;
completion();
}];
}
}
@EnD
#import <UIKit/UIKit.h>
#import <STPopup/STPopup.h>
@interface MobileUpdateOTPViewController : UIViewController
@EnD
#import "MobileUpdateOTPViewController.h"
@interface MobileUpdateOTPViewController ()
@implementation MobileUpdateOTPViewController
(instancetype)init
{
if (self = [super init]) {
self.title = @"Verification Code";
self.contentSizeInPopup = CGSizeMake(300, 400);
self.landscapeContentSizeInPopup = CGSizeMake(400, 200);
}
return self;
}
(void)viewDidLoad
{
[super viewDidLoad];
}
(void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
}
@EnD
`
I'm getting error
[STPopupController contentSizeOfTopView], ~/Pods/STPopup/STPopup/STPopupController.m:536
2017-06-07 17:40:48.249014+0530: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'contentSizeInPopup should not be size zero.'
Hello, there is a swift example for this?
Thanks!!
Hi kevin,
The image is overlapping on ActionSheet, See the attached image.
This situation occurs when the image is not download from server and popup appears before it.
After downloading and setting up the image .. this happen,
CGFloat imageWidth = [self.data[@"dimensions"][@"width"] doubleValue];
CGFloat imageHeight = [self.data[@"dimensions"][@"height"] doubleValue];
the above 2 lines will not work until the image downloaded.
So need to set the UI again after image downloading.
I've implemented 3d touch with a helper that receives the UICollectionView. From there I retrieve the pressed cell with the location from previewingContext:viewControllerForLocation:
.
I'd like to add this popupPreviewRecognizer to the UICollectionView as well, but I need the gesture location for determining which cell was pressed.
If i'm not mistaken, this library applies on iphone which doesn't have 3D touch. How about iphone 6S and above ? It does have 3D touch, can i use this library to preview my image? Or should i put different code applied for it's 3D touch function ?
Is it possible to use the long press to open and then leave the preview open?
Thanks
Is it possible to change the Blur background? Can I use the same functions as STPopup?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.