Toggle UITableViewCell in UITableView didSelectRowAtIndexPath - objective-c

I have a UITableView with some cells, where (for example) the first cell is a header, and the second cell contains a View.
I'd like to toggle the view's visibility when I press the header.
The press thingy is done in didSelectRowAtIndexPath, so can I set the visibility of another row from my UITableView (animated if possible)?
Can't find anything about it on Google..
Thanks!

You can reload the table and toggle the row count.

Sure if you know which cell you want to toggle then you can either get a hold of it with cellForRowAtIndexPath method of UITableView, or if you just want to reload the cell you can use reloadRowsAtIndexPaths:withRowAnimation: here is a ref

It works when I get the contentView of my UITableViewCell, and change the height of that view.

Related

scroll last Cell to top of UITableView

on my last cell is a dynamic textview. With bigger contentSize it will be stay on top of the tableview (to see it, while you fill it on keyboard), but if the textview and also the cell is going to be dynamically bigger: [tableview beginupdates] and [tableview endUpdates] will delete my contentSize. And after that it is scrolling it down to bottom of tableview.
Any ideas how to scroll the cell to the top, and create the cell also dynamically without changes on contentSize? maybe I'm thinking on the right way, ideas?
EDIT
Hmm..not any "correct" solution found...the best way for this purpose is to try set any new cells or sections below the textview to get this cell easy to top of the view. After this its easy to use it with beginUpdates and endUpdates. The cursor will be always in the textview, textview will be dynamically bigger also the cell, so the only easy way.
Another option is to set the uitableview as a subview of another scrollview (uitableview himself has one) to scroll up an down in the new scrollview.
Thanks for help.
From my experience, Text views in cells is a very tricky issue. I recommend just using the free Sensible TableView framework, which has text view cells available out of the box.

Is an created NSButtonCell unique?

So, is the button identifiable?
I need to identify a cell-botton (Button Cell) in aNSTableView in order to detect if it was pressed already. The table can always change by user input. My bright idea is if a created button (button cell) were unique it would be identifiable. Is that possible?
Cells are a little different from full-fledged controls. NSTableView reuses a single cell for all the rows of a column. When NSTableView draws a row, or when it handles user input, it configures the cell for the row/column in question.
It sounds like in your case you have an NSButtonCell and you want to know which row was clicked. You can determine which row was clicked by checking the table view's clickedRow property in the button cell's action method. The answer to this question explains how to do this.
Well, as long as these buttons are subclasses of UIView, which UIButtons are, then you can use the tag field to carry a numeric information. Set the button.tag in celForRowAtIndexPath to indexPath.row and you can fetch the tag within the IBAction method that the button should inovke when pressed.

How to delete Custom Table View Cell from the TableView of my ViewController?

In one of my ViewControllers, I added a tableview as a subview.
In this tableView I made implemented custom table view cell, which contains a remove button init.
So, when I clicked the remove, the data related is deleted, but the row in the tableview remains, it will disappear, when I reload my APP.
Can anyone help me out..
You have to use this method from UITableView:
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
The index path is the index of the row to remove.

Drawing table view cell when drag and drop

I have dragged an item into my tableview object.
When the dragged item hover over an item in tableview,
the item is redrawn with selection background. The image is as under
The row of the tableview is not selected, when i checked selectedRow method.
My requirement is when an item hover any item i should control its selection
and the background selection thereof.
Thanks,
iSight
To 'control' the selection of a TableViewCell when 'hovering' over such an item you will have to call this method:
- (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point
It's a method from the UITableView Class and uses the local coordinate system of your tableView. As is mentioned in the Apple Doc: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html
When the method is called you will have a NSIndexPath returned. With it you can select the cell/item at that particular path.
Mind, selecting a path manually doesn't call the didSelectRowAtIndexPath delegate-method so if you want a certain method called from that delegate you will have to do that manually as well!
This method is prolly called from the touchedDidMove method (where you also do the drag&drop) so getting the point needed for the method shouldn't be a problem for you.
You will figure it out :)
Good luck.

Position of UITableViewCell

I'm using a tableview to display a list of rows and when selected, I want additional controls to appear right below the cell, probably in another view which I will control.
So far, I've managed to get a reference to the selected cell by running through the visiblecells array in the tableview but the frame property always returns a y-coordinate of 0 no matter what scroll position the table is in.
How do I get the position of the cell relative to the window?
I think the best way to deal with table views is in their own terms. That is, if you want to position something new inside the table, put it in a cell. It sounds like you want to subclass UITableViewCell to make your controls, and go through the whole tableView beginUpdates - insertCells - endUpdates process to animate their appearance.