when I scroll position end of UItableview the last UItableview row seems half. how can I show the last row fully and how can I detect scroll to last row?
I don't know what you mean by "seems half". I suppose that means only half of the cell is shown? Make sure the frame of the whole table view is visible first.
If you want a cell to appear within the bounds of the table view, use
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:? section:?]
atScrollPosition:UITableViewScrollPositionBottom animated:YES];
I think there is something (like a tabBar) at the bottom of your screen and it is overlapping the UITableView .. am I right, am I right?!
Just make the frame of the UITableView 48 pixels shorter. That's the average size of a tabBar..
Or perhaps you have not taken in account that the bar at the top (the status bar) also counts, which is about 15 pixels high. In that case, take 15 pixels of the height of your UITableView's frame.
Related
I am using UITableViewAutomaticDimension to calculate height for my table view cell. It works fine for me. But for some cells, the height returned is 44 rather than dynamically calculating height. But on scrolling up an looking back to the same cell, the height is recalculated perfectly. So I guess I do not have any faulty constraints because, after I scroll and correct all cell heights manually, no constraint breaking warning are shown afterwards.
Edit
The below given is the screenshot of image(got messed up when cropped, but can see the issue from the profile image.). The first cell height is calculated correctly. But the rest are faulty.
I have added the following and everything worked fine.
(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
In my case it was something wrong with layoutMarginsGuide top and bottom anchor. I use it for cell subviews and set preservesSuperviewLayoutMargins = true for its subviews. This caused the mistake when system tried use systemLayoutSizeFitting to calculate cells height first time.
How to design this table view cell..
Cell overlaps the another cell.
Please help me
Set the y offset of the pictureImageview to be negative i.e -50.0f or so, the image will appear as starting from the cell above.
I just tried AppleDelegate's solution but didn't work, because the top of every image is cut, maybe because it is beyond the cells bounds, even with clear color for background.
A different approach would be to believe that it's just a visual effect, and cells are not overlapping. This is possible by giving a different height for every cell with next code :
- (CGFloat)tableView : (UITableView *) tableView
heightForRowAtIndexPath : (NSIndexPath *) indexPath {
// RETURN A DIFFERENT HEIGHT FOR EVERY CELL DEPENDING ON INDEXPATH,
// INCREASING IT GRADUALLY.
}
In the next image, the black lines look like cells' top border, but maybe that's the effect, and the real limit is the red line :
Thinking this way, only the first cell requires a special treatment for the green titles.
Try setting constraints in storyboard and then keep the UIImageView's size/frame of image same when the image is set to UIImageView. Good Luck!
I have a UISegmentedControl with 2 segments. I'm loading JSON data into a table view and each segment has different data. I first load the view and the default first segment shows up - data is there and cell height is perfect. When I tap on the second segment, all is well, the data loads properly and the cell height now matches this set of data. However, when I go back to the first segment the cell height is from the second, which is not what I want. Ideally the cells will resize for the first segment data like it originally did.
When I return to the first segment, how can I re-adjust the cell height so the data displays properly again?
You should implement
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
delegate method. and return the hight you want there.
My table view covers part of the view. If I have 20 objects, I am displaying all of them in a tableview. But I want to know that how many cell are loaded that are visible to the user.
(i.e. first 5 cells data is visible for me: when I scroll down, the remaining cells will load. Here I want to know without scrolling how many cell are loaded.)
Is this possible?
You can use [tableView visibleCells] count], which returns numbers of the table cells that are visible, if I understand correctly what you want.
The below code will give you the array of indexpath of cells currently visible
NSArray *visiblePaths = [self.tableView indexPathsForVisibleRows];
after getting the index path you can easily access the cell at a particular indexpath
Its usually : (tableView's height / cell row height ) + 1
Can you take the size of the visible part of the table, and then the size of one cell, and divide them to know how many of them fit in the screen?
i have table view(it has sections). at a time it will show only 4 images/rows(the height of table View is set according to that). when the scrolling is done, it will display 5th row half section,6th row full, 7th row full ,8th row full , 9th row half section as usual. however i don't want to show the half section of any rows. i need to show the complete sections of rows in my table view(it may be Rows 5,6,7,8 or Rows 6,7,8,9) after my scroll function is done. is any way to do it?any property for tableView to do it?
I think you should combine next methods:
scrollToRowAtIndexPath:atScrollPosition:animated:
Scrolls the receiver until a row identified by index path is at a particular location on the screen.
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
scrollViewDidEndDragging:willDecelerate:
Tells the delegate when dragging ended in the scroll view.
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
scrollViewDidEndDecelerating:
Tells the delegate that the scroll view has ended decelerating the scrolling movement.
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView