Ciel
Ciel

Reputation: 6281

ios uitableview bounce went wrong

I implemented a horizontal table view and it looks like this

enter image description here

The category bar, Dining Shopping something, is a horizontal table view and here is the implementation code.

LogInfo(@"Show Category Table start");
// add categories to be subview controller
self.categoriesTable = [[UITableView alloc] init];
self.categoriesTable.transform = CGAffineTransformMakeRotation(-M_PI * 0.5);
[self.categoriesTable setFrame:CGRectMake(0, 64, SCREENWIDTH, 44)];
self.categoriesTable.showsVerticalScrollIndicator = NO;
self.categoriesTable.showsHorizontalScrollIndicator = NO;
self.categoriesTable.pagingEnabled = YES;
self.categoriesTable.delegate = self;
self.categoriesTable.dataSource = self;
self.categoriesTable.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.superView addSubview:self.categoriesTable];
LogInfo(@"Show Category Table Finished");
self.categoriesTable.backgroundColor= [UIColor redColor];

It works as expect but if I change view, for example, I click any button to go to other view and go back to this view. The tableview looks like this

enter image description here

This problem also happpens even if I disable the bounce effect of the table view. Does anyone know how to solve this problem? Thanks!

Upvotes: 0

Views: 63

Answers (1)

rounak
rounak

Reputation: 9397

Rather than applying a transform to the table to make it horizontal, use a collectionView with a horizontal layout.

Edit: If you want to continue using your current setup, try disabling automaticallyAdjustsScrollViewInsets on your view controller.

self.automaticallyAdjustsScrollViewInsets = NO

Edit 2: If you're curious, since iOS 7 every view controller looks at its topmost/first scroll view and adjusts its contentInsets to compensate for the navigation bar transparency which is enabled by default. In this case of course, such behaviour isn't desired at all.

Upvotes: 2

Related Questions