MMPopLabel
MMPopLabel copied to clipboard
Library doesn't seem to be working as it should
Basically your popAtView function doesn't pop at the right place.
im running iOS 8 in an app that takes advantage auto layout and storyboards
I have tested this pod with Xcode 6.1.1, iOS 8 and AutoLayout and I am getting no issues. Can you provide an example?
Ya when I get a chance today ill share a link to some sample code.
Changed my issue to something more appropriate *
Ok so I am starting to think that I might have just jumped the gun trying to bridge your project into my swift project.
But here is the basics,
I put this sample in my viewDidLoad
*********************** BEGINNING OF CODE SNIPPET *****************
MMPopLabel.appearance().labelColor = UIColor.blueColor() MMPopLabel.appearance().labelTextColor = UIColor.whiteColor() MMPopLabel.appearance().labelTextHighlightColor = UIColor.greenColor() MMPopLabel.appearance().labelFont = UIFont.systemFontOfSize(14.0) MMPopLabel.appearance().buttonFont = UIFont.systemFontOfSize(16.0)
popLabel = MMPopLabel(text: "Some Text")
let skipButton = UIButton(frame: CGRectZero) skipButton.setTitle("Skip", forState: .Normal)
self.view.addSubview(popLabel) popLabel.popAtView(avatarImageView)
*********************** END OF CODE SNIPPET *****************
My AvatarImageView is sitting in the dead center of the screen. And the popLabel appears where my leftBarButtonItem is.
Is there something I am missing?
Even if I put the code to viewDidLayoutSubviews (aka after AutoLayout has done is calculations for frames) it still does not pop at the right place.
Do you think its just a Swift compatibility issue?
I'm definitely having a similar problem (swift project, XCode-6.1.1), but I haven't had time to delve into it too deeply.
The popup label is defined like this:
var passwordErrorLabel: MMPopLabel!
My view hierarchy is:
RootView (self.view)
UIScrollView (self.scrollView)
UITextView (self.passwordTextField)
Everything except for the passwordErrorLabel is setup via the storyboard, using AutoLayout.
Then in viewDidLoad():
MMPopLabel.appearance().labelColor = UIColor.blueColor()
MMPopLabel.appearance().labelColor = textFieldErrorBackgroundColor
MMPopLabel.appearance().labelTextColor = UIColor.whiteColor()
MMPopLabel.appearance().labelTextHighlightColor = UIColor.redColor()
MMPopLabel.appearance().labelFont = buttonFont
MMPopLabel.appearance().buttonFont = buttonFont
passwordErrorLabel = MMPopLabel(text: "Password must be at least 8 characters")
self.scrollView.addSubview(passwordErrorLabel)
// I also tried:
// self.view.addSubview(passwordErrorLabel) with the same results.
If the user's pw doesn't meet the password policy criteria, I call (from within func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool
:
self.passwordErrorLabel.popAtView(self.passwordTextField)
The screen looks like this:
Does it have anyhthing to do with the passwordTextField not being in the root hierarchy directly or in a scrollview?
It's something with the first part of popAtView():
if ([[view superview] superview] != self.window) {
center = [self.window convertPoint:view.center fromView:view];
}
If I comment this out, it works properly.
@SuperTango I can confirm the exact same behavior.
Xcode 6.3 - Objective C
center
is getting translated by convertPoint:
from x:338.5, y:644
to x:656.5, y:1273
The view hierarchy is
UIWindow
|-UILayoutContanerView
|-UINavigationTransitionView
|-UIViewControllerWrapperView
|-UIView
|-UIButton (view)
Could it be that all of the transition views automatically created by AutoLayout are creating difficulties for this test?
Commenting out the same section of code works for me.
@SuperTango Confirmed. It took me a bit to figure this out, should have checked the open issues, but removing this fixed the positioning problems on the iPad.
I'm having the same issue. The MMPopLabel was originally covering the view. Then later it is started popuping up way below the view similar to the image above.
How can I fix it.
The view is controlled by autolayout. I am on a ipad.
For a quick fix, try changing the following code in MMPopLabel.m, line 204:
CGPoint center = view.center; if ([[view superview] superview] != self.window) { center = [self.window convertPoint:view.center fromView:view]; } self.center = center;
with this:
self.center = [view.superview convertPoint:view.center toView:[UIApplication sharedApplication].keyWindow.rootViewController.view]; CGPoint center = self.center;
This should solve your problem. I'll be updating the pod ASAP with this change.
I'll check if the workaround works and let you know. However there is another bug.
My PopLabel doesn't have any buttons. Just text. I want it to dismiss when I tap on the PopLabel.
I don't think - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
works.
It takes many many many taps and it's totally predictable on when it does dismiss.
Here is a fix:
Inside : - (id)initWithText:(NSString *)text
add:
[self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)]];
Inside : - (void)addButton:(UIButton *)button
add:
[self.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
obj.enabled = NO;
}];
[self.buttons addObject:button];
Could you please add those in and then the class should be all good.
We have the same problem with the position of the label.. but your workaround does not work :(
SAME PROBLEM :(
The fix from "mgcm" coment worked for me!!! I'm having a issue to change the text to display multiples tips. I didnt find any text property. Anyone give me a hint?
CASE CLOSED:
This guy's fork solves the problem: https://github.com/kouheiszk/MMPopLabel
if (view.superview != self.superview) {
+ center = [self.superview convertPoint:center fromView:view.superview];
}
self.center = center;