I have a set up a grouped tableview where i have overridden the following delegate method:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
The headerview gets rendered and everything looks fine... in portrait mode.
If i now rotate my device the headerview is now not aligned with the table cells.
This is because the tableview has added more left and right spacing for the cells in landscape than in portrait.
From what i can tell this is not a UIViewAutoresizeMask question because the tableview cells have a varying amount of space on the left and right side depending if the iDevice is in landscape or portrait mode.
I would appreciate ANY solutions / suggestions to this problem!
UPDATE:
The problem seems to be when a tableview has a position x > 0. Notice the difference in left and right space for the table cell.
First image is in portrait mode
Second is in landscape mode
Related
I have a TableView controller, and the tableView cells were added statically.
as shown in the image_1 below, I have 18 cells. but the problem I have now is, when I change the screen orientation to Landscape, the simulator can not display the entire cells inside the TableView controller, it displays only 8 cells as shown in image_2.
please let me know how to display all cells while in landscape mode.
image_1:
image_2:
If you want to fit all the cells, I think, you can either check the current orientation and decrease the cell heights or You always can use collection view and also change the item sizes relative to orientation.
In an app for iPad, I have a view controller 'A' with a collectionview that displays differently based on the orientation, i.e. vertically scrolling in landscape & horizontally scrolling in portrait. I have 2 separate uicollectionviewlayouts to achieve this, with different cells registered and everything, which I set when device orientation changes.
The problem is when I push a view controller 'B' in response to clicking the collectionview cells in 'A', say in portrait mode & I now switch the device to landscape mode (while in 'B'). Now on clicking back from 'B' to 'A', the layout of the collectionview has changed to horizontally scrolling, however the visible cells displaying are out of place :( Manually scrolling the collectionview or manually changing orientations (rotate device to portrait & then again to landscape) when back to view 'A' is the only way which makes the cells display properly. I've done everything from invalidating the layouts and setting it on orientation change for view 'B' in view 'A' and even tried all the reloading stuff such as
[self.collectionView reloadData]; as well as
[self.collectionView reloadItemsAtIndexPaths:[self.collectionView indexPathsForVisibleItems]];
However, neither of these work. I'm assuming its because the view 'A' is not visible when view controller 'B' is pushed onto 'A' is causing the issue. I'd like some guidance how to fix this problem as I'm at my wits end.
Currently I have a custom table view cell and I want to match the re-useable cell's bottom to the top of the tab bar, wrt given iPhone size dimensions (i.e. as dynamic as it can be). Basically, on the first run without a finger scroll, the cell should fit the area from navigation bar's bottom to the tab bar's top. I believe it is just like this for apps like instagram, vine etc.
How can I achieve this, especially without using some library etc.? Do I have to use something like a pod for ease of implementation or current limitations?
Set the rowHeight Property of the cell
[tableView setRowHeight:CGRectGetHeight(self.view.bounds)];
This will return the height starting from navBar bottom edge and Tabbar's top edge.
You could also set the cell's height in the table view delegate method below:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return CGRectGetHeight(self.view.bounds);
}
I have a collection view with 5 rows with each row consisting of 3 cells in each row in Portrait orientation on the view. In landscape, it has 3 x 4 cells, with half visible 4th row. For example, if a cell index is 5, it appears as below:
Portrait - second row, second cell.
Landscape - Second row, first cell.
If for instance, in Portrait mode, the collection view is scrolled down with an offset. And if the orientation is changed to Landscape, is it possible to
1) find out the exact position of the cell after applying appropriate content offset?
2) find out the scroll offset in the new orientation?
I will need the position without reloading the view in the orientation. By position, I mean the center of the cell. And the scroll offset too?
Would it be possible? Would it be a right approach, if I load the contents on an offscreen collection view and scroll to the cell to find its position?
Please help!!
I have tried a work around here.
I am trying to reload the collection view with the change in orientation and scroll to the selected cell at scroll position UICollectionViewScrollPositionCenteredVertically. Now, I know the position of the cell according to the cell index.
I have UIViewController with a UIView with UITableView inside.
All works fine in Landscape mode but when the device is rotated to Portrait, bottom half of UITableView is not accessible (can't even select any row in the bottom half or make table scroll). All rows are displayed correctly.
I am re-framing and repositioning UIView and UITableView on rotation.
Any ideas how to solve this problem?
You should adjust the autosizing in Interface Builder or in code.
I think the UITableView's height is still same with the value in Landscape mode after you rotate device to Portrait.
You can identify it by NSlog your UITableView's CGRect
NSlog(#"frame:%#",[NSStringFromCGRect(UITableView's CGRect)]);