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

Sections #12

Closed
BrandonCopley opened this issue Feb 29, 2012 · 4 comments
Closed

Sections #12

BrandonCopley opened this issue Feb 29, 2012 · 4 comments

Comments

@BrandonCopley
Copy link
Contributor

Alright why couldn't we implement headers and footers? I believe I have added headers and footers and done a great implementation.

Can I share this code?

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if ([delegate respondsToSelector:@selector(easyTableView:viewForHeaderInSection:)]) {
return [delegate easyTableView:self viewForHeaderInSection:section];
}
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
}

-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

if ([delegate respondsToSelector:@selector(easyTableView:viewForFooterInSection:)]) {
    return [delegate easyTableView:self viewForFooterInSection:section];
}
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

if ([delegate respondsToSelector:@selector(numberOfSectionsInEasyTableView::)]) {
    return [delegate numberOfSectionsInEasyTableView:self];
}

return 1;

}

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSUInteger numOfItems = _numItems;

    if ([delegate respondsToSelector:@selector(numberOfCellsForEasyTableView:inSection:)]) {
    numOfItems = [delegate numberOfCellsForEasyTableView:self inSection:section];

    // Animate any changes in the number of items
    [tableView beginUpdates];
    [tableView endUpdates];
    

    }

    return numOfItems;
    }

  • (UIView *)viewAtIndex:(NSUInteger)index inSection:(NSInteger)section{
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:section];
    UIView *cell = [self.tableView cellForRowAtIndexPath:indexPath];

    return [cell viewWithTag:CELL_CONTENT_TAG];
    }

in the .h

  • (NSUInteger)numberOfCellsForEasyTableView:(EasyTableView *)view inSection:(NSInteger)section;
  • (NSUInteger)numberOfSectionsInEasyTableView:(EasyTableView*)easyTableView;
  • (UIView_)easyTableView:(EasyTableView_)easyTableView viewForHeaderInSection:(NSInteger)section;
  • (UIView_)easyTableView:(EasyTableView_)easyTableView viewForFooterInSection:(NSInteger)section;
  • (UIView *)viewAtIndex:(NSUInteger)index inSection:(NSInteger)section;

This seems to work swimmingly.

@alekseyn
Copy link
Owner

That looks great. I never tested it before, assuming it was going to be problematic. But it's nice to know it just works. Feel free to issue a Pull Request, or I can just merge your code from the blog post. Thanks!

@alekseyn
Copy link
Owner

alekseyn commented Mar 1, 2012

I've merged your changes, but in the process made numerous other changes to support multiple sections. Most of my changes were stylistic, though some were functional changes too. I decided to break the existing interface just to keep it simpler for newer users. Existing users shouldn't have much difficulty in fixes required to use the new method calls. I've documented mostly everything in the README. Do you mind pulling my latest changes just to make sure everything still works for you? You might see a bug or two where you need to replace "index" with "indexPath". Thanks.

Your app Comic Turtle looks great! Well done. And thanks for letting me know that EasyTableView has been used successfully in a production app! I've used EasyTableView with a number of clients, but their apps have yet to be released, and I have not used it in any of my own Yodel Code branded apps. Thanks again for helping with the extensions for multiple sections and section headers and footers.

@BrandonCopley
Copy link
Contributor Author

Great,

I will yes soon - I'm working on now allowing rotated headers an
footers, they work but everything shows up rotated :P.

Brandon

On Mar 1, 2012, at 5:56 PM, Aleksey Novicov
reply@reply.github.com
wrote:

I've merged your changes, but in the process made numerous other changes to support multiple sections. Most of my changes were stylistic, though some were functional changes too. I decided to break the existing interface just to keep it simpler for newer users. Existing users shouldn't have much difficulty in fixes required to use the new method calls. I've documented mostly everything in the README. Do you mind pulling my latest changes just to make sure everything still works for you? You might see a bug or two where you need to replace "index" with "indexPath". Thanks.

Your app Comic Turtle looks great! Well done. And thanks for letting me know that EasyTableView has been used successfully in a production app! I've used EasyTableView with a number of clients, but their apps have yet to be released, and I have not used it in any of my own Yodel Code branded apps. Thanks again for helping with the extensions for multiple sections and section headers and footers.


Reply to this email directly or view it on GitHub:
#12 (comment)

@alekseyn
Copy link
Owner

alekseyn commented Mar 3, 2012

I'll carry on this thread under Issue #14.

@alekseyn alekseyn closed this as completed Mar 3, 2012
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