alekseyn / EasyTableView

Horizontal and vertical scrolling table views for iOS
BSD 3-Clause "New" or "Revised" License
584 stars 157 forks source link

Section Header Views and rotating the device #21

Closed BrandonCopley closed 12 years ago

BrandonCopley commented 12 years ago

Section header views seem to get "stuck" on rotation -

I think it has something to do with this method and the addSubview method...If I disable the "addSubview" method they don't get stuck, perhaps we need an image tag? I don't quite know yet.

BrandonCopley commented 12 years ago

I added this method:

-(void)reloadData{ UIView *removeView;

while((removeView = [self.tableView viewWithTag:HEADER_VIEW_TAG]) != nil) {
    [removeView removeFromSuperview];
}

[self.tableView reloadData];

}

and then:

I'd push, but I'm not 100% this fixes it...

alekseyn commented 12 years ago

I reviewed the EasyTableView source code and everything is fine. If you disable the -addSubview it won't work. Given that you said it works for you after you disable it, leads me to believe your delegate implementation may be doing something strange. The sample code works fine as is. Are you seeing something broken with the sample code?

BrandonCopley commented 12 years ago

I made a note as to how this gets fixed - it seems that for some reason the headerview hangs around if you rotate the device a few times.

brandon

On Mon, Jun 18, 2012 at 12:51 AM, Aleksey Novicov < reply@reply.github.com

wrote:

I reviewed the EasyTableView source code and everything is fine. If you disable the -addSubview it won't work. Given that you said it works for you after you disable it, leads me to believe your delegate implementation may be doing something strange. The sample code works fine as is. Are you seeing something broken with the sample code?


Reply to this email directly or view it on GitHub: https://github.com/alekseyn/EasyTableView/issues/21#issuecomment-6388379

http://novationmobile.com/

Brandon Copley

CHIEF OPERATING OFFICER

PHONE::: 512.784.6060 EMAIL::: copley.brandon@gmail.com copley.brandon@gmail.com WEBSITE::: http://novationmobile.com/ http://www.novationmobile.com

BrandonCopley commented 12 years ago

The delegate simply returns a UIView - nothing fancy.

On Mon, Jun 18, 2012 at 1:14 AM, Brandon Copley copley.brandon@gmail.comwrote:

I made a note as to how this gets fixed - it seems that for some reason the headerview hangs around if you rotate the device a few times.

brandon

On Mon, Jun 18, 2012 at 12:51 AM, Aleksey Novicov < reply@reply.github.com

wrote:

I reviewed the EasyTableView source code and everything is fine. If you disable the -addSubview it won't work. Given that you said it works for you after you disable it, leads me to believe your delegate implementation may be doing something strange. The sample code works fine as is. Are you seeing something broken with the sample code?


Reply to this email directly or view it on GitHub: https://github.com/alekseyn/EasyTableView/issues/21#issuecomment-6388379

http://novationmobile.com/

Brandon Copley

CHIEF OPERATING OFFICER

PHONE::: 512.784.6060 EMAIL::: copley.brandon@gmail.com copley.brandon@gmail.com WEBSITE::: http://novationmobile.com/ http://www.novationmobile.com

http://novationmobile.com/

Brandon Copley

CHIEF OPERATING OFFICER

PHONE::: 512.784.6060 EMAIL::: copley.brandon@gmail.com copley.brandon@gmail.com WEBSITE::: http://novationmobile.com/ http://www.novationmobile.com

alekseyn commented 12 years ago

Hmm, are you able to replicate the problem with the sample code?

alekseyn commented 12 years ago

Are you using ARC?

BrandonCopley commented 12 years ago

yes using ARC, have not tried with the sample code, I'll try that shortly. It should happen if I have an understanding of what's going on...but I'll try at some point tomorrow.

On Mon, Jun 18, 2012 at 1:23 AM, Aleksey Novicov < reply@reply.github.com

wrote:

Are you using ARC?


Reply to this email directly or view it on GitHub: https://github.com/alekseyn/EasyTableView/issues/21#issuecomment-6388699

http://novationmobile.com/

Brandon Copley

CHIEF OPERATING OFFICER

PHONE::: 512.784.6060 EMAIL::: copley.brandon@gmail.com copley.brandon@gmail.com WEBSITE::: http://novationmobile.com/ http://www.novationmobile.com

alekseyn commented 12 years ago

It really seems like the issue is somewhere else. The code your reference above is somewhat meaningless because once the view is handed over to UITableView, it owns it.

BrandonCopley commented 12 years ago

It seems to me that the bug is how the uitableview headerview deals with subviews, still haven't looked at the sample to see if i can make it bug out - will do shortly.

On Mon, Jun 18, 2012 at 6:43 PM, Aleksey Novicov < reply@reply.github.com

wrote:

It really seems like the issue is somewhere else. The code your reference above is somewhat meaningless because once the view is handed over to UITableView, it owns it.


Reply to this email directly or view it on GitHub: https://github.com/alekseyn/EasyTableView/issues/21#issuecomment-6412456

http://novationmobile.com/

Brandon Copley

CHIEF OPERATING OFFICER

PHONE::: 512.784.6060 EMAIL::: copley.brandon@gmail.com copley.brandon@gmail.com WEBSITE::: http://novationmobile.com/ http://www.novationmobile.com

BrandonCopley commented 12 years ago

Here is the code in my delegate:

}

and in headerView:

-(id)initWithFrame:(CGRect)frame{

if (self = [super initWithFrame:frame]) {

    [[NSBundle mainBundle] loadNibNamed:

@"HomeComicTableViewHeader_iPhone" owner:self options:nil];

    self.autoresizingMask = UIViewAutoresizingFlexibleWidth |

UIViewAutoresizingFlexibleHeight;

    self.backgroundColor = [UIColor clearColor];

    self.clipsToBounds = YES;

    view.frame = self.bounds;

    [self addSubview:view];

}

return self;

}

On Mon, Jun 18, 2012 at 6:45 PM, Brandon Copley copley.brandon@gmail.comwrote:

It seems to me that the bug is how the uitableview headerview deals with subviews, still haven't looked at the sample to see if i can make it bug out - will do shortly.

On Mon, Jun 18, 2012 at 6:43 PM, Aleksey Novicov < reply@reply.github.com

wrote:

It really seems like the issue is somewhere else. The code your reference above is somewhat meaningless because once the view is handed over to UITableView, it owns it.


Reply to this email directly or view it on GitHub: https://github.com/alekseyn/EasyTableView/issues/21#issuecomment-6412456

http://novationmobile.com/

Brandon Copley

CHIEF OPERATING OFFICER

PHONE::: 512.784.6060 EMAIL::: copley.brandon@gmail.com copley.brandon@gmail.com WEBSITE::: http://novationmobile.com/ http://www.novationmobile.com

http://novationmobile.com/

Brandon Copley

CHIEF OPERATING OFFICER

PHONE::: 512.784.6060 EMAIL::: copley.brandon@gmail.com copley.brandon@gmail.com WEBSITE::: http://novationmobile.com/ http://www.novationmobile.com

alekseyn commented 12 years ago

You should be loading the nib file in the EasyTableView delegate method, and letting it do the initialization for you when it calls initWithCoder. You are going to get goofy results with the way you are doing it now. See http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html

BrandonCopley commented 12 years ago

Hm, I have not tried loading the nib in that fashion before, but you're right it may all come down to the nib loading wrong as I can't recreate - so proper is?

NSArray subviewArray = [[NSBundle mainBundle] loadNibNamed:@"nibName" owner:self options:nil]; UIView view = [subviewArray objectAtIndex:0];

I don't see why this would be any different, but perhaps that is the issue:

alekseyn commented 12 years ago

I think the problem with the way you are doing it is that you end up with two instances of TableViewHeader_iPhone. Apple recommends using UINib for these purposes:

UINib *nib = [UINib nibWithNibName:@"TableViewHeader_iPhone" bundle:nil];
[nib instantiateWithOwner:self options:nil];

This link might be useful for you:

http://useyourloaf.com/blog/2011/02/28/speeding-up-table-view-cell-loading-with-uinib.html