Open trungnguyen1791 opened 9 years ago
Do you mean a delegate for making text overlay?
Yep, do you have any ideas? For example, if user swiping to the left corner, a delegate will call "swiping to left, show smthing..."
I just added this delegate for obtaining the offset of user's finger translation. Right now you can use the translation
parameter to set the alpha of the text overlay. If translation.x
is smaller than self.relativeDisplacementThreshold*self.bounds.size.width
, the top view will swipe left, and vice versa.
- (void)swipeableView: (ZLSwipeableView *)swipeableView swipingView:(UIView *)view atLocation:(CGPoint)location translation:(CGPoint)translation {
NSLog(@"swiping at location: x %f, y %f, translation: x %f, y %f", location.x, location.y, translation.x, translation.y);
}
Thanks so much for this. I have one more question. Can we keep the view's data sources in an array or dictionary? Like the UITableView or UICollectionView. Now we didn't, so if my view has a button, then i try to tap on that button, it will send a message to deallocated view. And of of course it make my app crash
Currently, ZLSwipeableView adds all the views provided by the data source to its view hierarchy as its subviews (subviews are held by strong pointers).
After a view is swiped, ZLSwipeableView simply remove it from the view hierarchy. At this point, if the swiped view is not held by any other strong pointers, it will be garbage collected (like in the demo app).
If you want to use the swiped view afterwards, you should keep a strong reference to it (for instance, by storing the views provided by the data source in an array, which seems like what you are suggesting).
Hmm, i don't want to swipe view afterwards. Just try to place a button on that. But always crash when try to tap on button.
Let me check again. Thanks for your information
Could you show me the code?
The only difference in my code is that i've use a custom view controller with xib instead of CardView (like in the sample project).
And i try to create my view like that : ProfileView *view = [ProfileView customView];
---in ProfileView
(id)customView { ProfileView customView = [[[NSBundle mainBundle] loadNibNamed:@"ProfileView" owner:nil options:nil] lastObject]; //// Color Declarations UIColor shadowColor2 = [UIColor colorWithRed: 0.209 green: 0.209 blue: 0.209 alpha: 1];
//// Shadow Declarations UIColor* shadow = [shadowColor2 colorWithAlphaComponent: 0.73]; CGSize shadowOffset = CGSizeMake(3.1/2.0, -0.1/2.0); CGFloat shadowBlurRadius = 12/2.0; customView.layer.shadowColor = [shadow CGColor]; customView.layer.shadowOpacity = 0.73; customView.layer.shadowOffset = shadowOffset; customView.layer.shadowRadius = shadowBlurRadius; customView.layer.shouldRasterize = YES;
// make sure customView is not nil or the wrong class! if ([customView isKindOfClass:[ProfileView class]]) return customView; else return nil; }
I think this's the source of my problem :D
where is the button you mentioned?
In the ProfileView.xib.
shouldn't this
ProfileView customView = [[[NSBundle mainBundle] loadNibNamed:@"ProfileView" owner:nil options:nil] lastObject];
be this?
ProfileView *customView = [[[NSBundle mainBundle] loadNibNamed:@"ProfileView" owner:nil options:nil] lastObject];
Oh, just a mistake when i copy from Xcode to here. Already "ProfileView *customView"
The new version of the sdk I find that you have to put some property before deleted, for example: self.relativeDisplacementThreshold, swipeableViewsCenter..I want to achieve and tinder, slide left or right slide when the card appears like it or not tag
I wanna make a swipeable view like tinder. So when ever use swipe to left or right, the correspoding button will highlight too.
May be we need a delegate like willSwipeLeft ?