Show the complete sections of rows in my table view after scrolling is done - objective-c

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

Related

NSOutlineView numberOfRows doesn't increase after reloadData

I want to calculate the size of a cell that I've just added to an NSOutlineView. To do that, I add it to my data source, and then call reloadData on the NSOutlineView. For some reason, however, I can't examine the cell after reloadData for any but the very first row. The code looks like this:
[m_dataSource add:...]; // first add item to my data source
[m_outlineView reloadData];
int nRows = (int) [m_outlineView numberOfRows];
NSCell *cell = [m_outlineView preparedCellAtColumn:0 row:nRows-1];
NSSize size = [cell cellSize];
For some reason, nRows is always 1 here, no matter how many rows I add. Thus, I can only ever query the size of the first cell in the very first row.
The behaviour I see might be related to the fact that the very first row is an expandable row and all other rows are children of the very first row. However, I have checked that
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
correctly returns YES for the item. Everything also appears correctly in the NSOutlineView. It's just that numberOfRows doesn't seem to get updated even though I call reloadData just before it.
Any ideas what's wrong here?

Design tableViewCell( overlaps table view cell)

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!

Changing Segments Alters Cell Height - How do I revert back?

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.

How to increase the row height in NSTableView based on the text Content?

How to increase the row height in a NSTableView based on the text Content.Row height should be increased when there is more text and the row should shrink when the text is deleted.
I implemented the textDidChange notification in my subclass of NSTableView,but I did not find any method which will increase the row height. setRowHeight of NSTableView will increase the height of every row in the tableview. I would like to a variable row height.Can I have any sample code or any pointers to accomplish this.
I found the following link
http://cocoadev.com/forums/discussion/1851/calculating-row-heights
But I am not able to find any example on this!. Any example on this would be a great help for me!
Tried to implement the following deleagate
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
by calculating the string length,Now I am able to increase the row height ,but the NSTextFieldCell height is same. How can I increase the height of the textfield when the row height changes.
corbin dunn gave a solution:
fix your autoresizing/AutoLayout coinstraints so the text view sticks to its container,
calculate the row height -tableView:heightOfRow: with the help of a custom NSTableCellView
object.
You can increase height of tableviewrow in the method - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {} . Call [tableView reloadData] in textDidFinishEditing to reload the table .

set scroll last UItableview cell

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.