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

QSection footer height is always 28.0 when it's set to a string #32

Closed
karlozm opened this issue Dec 8, 2011 · 2 comments
Closed

QSection footer height is always 28.0 when it's set to a string #32

karlozm opened this issue Dec 8, 2011 · 2 comments

Comments

@karlozm
Copy link

karlozm commented Dec 8, 2011

Problem
When setting the section footer using a string its height is always 28 regardless of its length

Proposed code solution
I'm not pushing my copy of the code, i'm assuming you might want to use your own coding standards and because i don't know if you want to delegate this task to the user or directly integrate it.

This code will calculate the height for the footer.

QuickDialogTableDelegate.m (tableView:heightForFooterInSection:)

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)index {
    QSection *section = [_tableView.root getSectionForIndex:index];
    CGFloat stringFooterHeight = 28.0;

    if (section.footerView!=nil)
            return section.footerView.frame.size.height;

    if (section.footer != nil) {
        CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width - 50;
        CGFloat maxHeight = 9999;
        CGSize maximumLabelSize = CGSizeMake(maxWidth,maxHeight);
        CGSize expectedLabelSize = [section.footer sizeWithFont:[UIFont systemFontOfSize:[UIFont labelFontSize]]
                                              constrainedToSize:maximumLabelSize
                                                  lineBreakMode:UILineBreakModeWordWrap];

        stringFooterHeight = expectedLabelSize.height;
    }

    return section.footer != NULL? stringFooterHeight : 0;
}
@escoz
Copy link
Owner

escoz commented Dec 8, 2011

Thanks! I've never tried it, so I'll look into it when I can.

Please feel free to create a pull request if you want, I can always merge
it first, and then change the code if necessary.. I'll take any help I can
get! :)

On Thu, Dec 8, 2011 at 1:15 PM, Karloz Medina <
reply@reply.github.com

wrote:

Problem
When setting the section footer using a string its height is always 28
regardless of its length

Proposed code solution
I'm not pushing my copy of the code, i'm assuming you might want to use
your own coding standards.

This code will calculate the height for the footer.

QuickDialogTableDelegate.m (tableView:heightForFooterInSection:)

- (CGFloat)tableView:(UITableView *)tableView
heightForFooterInSection:(NSInteger)index {
   QSection *section = [_tableView.root getSectionForIndex:index];
       CGFloat stringFooterHeight = 28.0;

   if (section.footerView!=nil)
           return section.footerView.frame.size.height;

       if (section.footer != nil) {
               CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width
- 50;
               CGFloat maxHeight = 9999;
               CGSize maximumLabelSize = CGSizeMake(maxWidth,maxHeight);
               CGSize expectedLabelSize = [section.footer
sizeWithFont:[UIFont systemFontOfSize:[UIFont labelFontSize]]

               constrainedToSize:maximumLabelSize

                       lineBreakMode:UILineBreakModeWordWrap];

               stringFooterHeight = expectedLabelSize.height;
       }

   return section.footer != NULL? stringFooterHeight : 0;
}

Reply to this email directly or view it on GitHub:
#32

escoz added a commit that referenced this issue Dec 29, 2011
@escoz
Copy link
Owner

escoz commented Dec 29, 2011

Thanks for the help! I ended up committing exactly what you suggested, just included a simple test case.

@escoz escoz closed this as completed Dec 29, 2011
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

2 participants