Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message do not appear correctly in iOS7 and 64-bit #58

Closed
Willaw opened this issue Dec 30, 2013 · 8 comments
Closed

Message do not appear correctly in iOS7 and 64-bit #58

Willaw opened this issue Dec 30, 2013 · 8 comments

Comments

@Willaw
Copy link

Willaw commented Dec 30, 2013

When running in 64-bit and iOS7, the message do not appear correctly (in blank or with only one line).

@Willaw
Copy link
Author

Willaw commented Dec 30, 2013

Chris, I'm new at Github. I correct the method to display correctly :

The code :

// Draw title and text
if (self.title) {
[self.titleColor set];
CGRect titleFrame = [self contentFrame];

    //=========================
    //CORREÇÃO PARA IOS7 64-BIT
    //=========================
    NSMutableParagraphStyle *paragrafo = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    paragrafo.lineBreakMode            = NSLineBreakByClipping;
    paragrafo.alignment                = self.titleAlignment;
    NSDictionary *atributos            = @{ NSFontAttributeName: self.titleFont, NSParagraphStyleAttributeName: paragrafo };
    [self.title drawInRect:titleFrame withAttributes:atributos];

}

if (self.message) {
    [self.textColor set];
    CGRect textFrame = [self contentFrame];

    // Move down to make room for title
    if (self.title) {
        textFrame.origin.y += [self.title sizeWithFont:self.titleFont
                                     constrainedToSize:CGSizeMake(textFrame.size.width, 99999.0)
                                         lineBreakMode:NSLineBreakByClipping].height;
    }

   //=========================
   //CORREÇÃO PARA IOS7 64-BIT
   //=========================
   NSMutableParagraphStyle *paragrafo = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
   paragrafo.lineBreakMode            = NSLineBreakByWordWrapping;
   paragrafo.alignment                = self.textAlignment;
   NSDictionary *atributos            = @{ NSFontAttributeName: self.textFont, NSParagraphStyleAttributeName: paragrafo };
   [self.message drawInRect:textFrame withAttributes:atributos];

}

@Willaw
Copy link
Author

Willaw commented Dec 30, 2013

img_2998

This is how the image appear before the correction.

@Willaw
Copy link
Author

Willaw commented Dec 30, 2013

After the correction, the result :

img_2999

@funnel20
Copy link
Contributor

Hi, thank you for the update.
It works, but doesn't take into account the properties for titleColor and textColor.

According to Apple dos:
NSForegroundColorAttributeName
The value of this attribute is a UIColor object. Use this attribute to specify the color of the text during rendering. If you do not specify this attribute, the text is rendered in black.

Therefor I extended your code by specifying the NSForegroundColorAttributeName while creating NSDictionary *atributos.

Also this update is not backwards compatibel with iOS 6, so I have added both based on the iOS version.
Resulting code:

// Draw title and text
if (self.title) {
[self.titleColor set];
CGRect titleFrame = [self contentFrame];

    // Fix for issue #58, see https://github.com/chrismiles/CMPopTipView/issues/58
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        //=========================
        //CORREÇÃO PARA IOS7 64-BIT
        //=========================
        NSMutableParagraphStyle *paragrafo = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
        paragrafo.lineBreakMode            = NSLineBreakByClipping;
        paragrafo.alignment                = self.titleAlignment;
        NSDictionary *atributos            = @{ NSFontAttributeName: self.titleFont, NSParagraphStyleAttributeName: paragrafo, NSForegroundColorAttributeName: self.titleColor };
        [self.title drawInRect:titleFrame withAttributes:atributos];
    }
    else {
        [self.title drawInRect:titleFrame
                      withFont:self.titleFont
                 lineBreakMode:NSLineBreakByClipping
                     alignment:self.titleAlignment];
    }
}

if (self.message) {
    [self.textColor set];
    CGRect textFrame = [self contentFrame];

    // Move down to make room for title
    if (self.title) {
        textFrame.origin.y += [self.title sizeWithFont:self.titleFont
                                     constrainedToSize:CGSizeMake(textFrame.size.width, 99999.0)
                                         lineBreakMode:NSLineBreakByClipping].height;
    }

    // Fix for issue #58, see https://github.com/chrismiles/CMPopTipView/issues/58
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        //=========================
        //CORREÇÃO PARA IOS7 64-BIT
        //=========================
        NSMutableParagraphStyle *paragrafo = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
        paragrafo.lineBreakMode            = NSLineBreakByWordWrapping;
        paragrafo.alignment                = self.textAlignment;
        NSDictionary *atributos            = @{ NSFontAttributeName: self.textFont, NSParagraphStyleAttributeName: paragrafo, NSForegroundColorAttributeName: self.textColor };
        [self.message drawInRect:textFrame withAttributes:atributos];
    }
    else {
        [self.message drawInRect:textFrame
                        withFont:self.textFont
                   lineBreakMode:NSLineBreakByWordWrapping
                       alignment:self.textAlignment];
    }
}

@nicked
Copy link

nicked commented Apr 27, 2014

This appears to be fixed in 2.2.0

@funnel20
Copy link
Contributor

Hi,
I have used version 2.2.0, but unfortunately it changes the width of the popview in a negative way. Also the property maxWidth is ignored completely.

Examples:

Previous version with manual adjustments from this post:
screenshot 2014 04 28 14 19 07

Version 2.2.0:
screenshot 2014 04 28 14 21 45

On iPhone it's even worse:
old:
screenshot 2014 04 28 14 20 03

new:
screenshot 2014 04 28 14 21 00

Sorry, I maintain my modified previous version.

@chrismiles
Copy link
Owner

Can you please raise the width issue as a separate bug on 2.2.0?

Similarly for any other issues on 2.2.0, a specific issue for each will help target fixes.

Cheers,
Chris

@funnel20
Copy link
Contributor

funnel20 commented Dec 2, 2014

I have created a new issue: #82

Please close #58, since that is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants