Reputation: 531
I have a UITableViewCell which is currently cluttered and has too much information on the screen at once. I want to make a button, that when pushed, a small view will slide down and show the remaining information, and then when pushed again it will slide back to the original size. I was wondering how I go about doing something like this. I know NOTHING about doing this, so please be specific when pointing me in a certain direction. Thanks!
Upvotes: 1
Views: 1343
Reputation: 136
Do you want single Button for all cells in table view or you want to add button as subview on each cell
1.if you want to add button as subview on each cell
a) Add button with tag value equals to indexPath.row
and set target to single method for each button.
ex
-(void)infoButonTapped:(UIButton *)sender;
Now on Click on button find the tag value of button and get the info from the array which you use to populate UITableViewCell
s.
b) Now create a infoview and add textview on it and set info as text prop of text view and add infoview as subview of view using UIView
Animation and hide on next click
you can either use a bool variable in .h file to know hide or show infoView or you can check if infoview has superview then you have to hide infoview else add infoview as subview of self.view.
a) Now on click of button get indexPath
for selected cell of tableview using tableview method
- (NSIndexPath *)indexPathForSelectedRow;
this method either return indexpath for selected cell or nil in case no cell selected
Use indexpath for get info from the array and add infoview as subview to view using step 1.b explained above.
you can also get the rect of selected row for setting the cordinate for the info view by method of tableview
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath;
Upvotes: 1
Reputation: 125
In this case, you better use the following method: -
(void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation{
}
Make a call to above method in your UITableView
didselectRowAtIndexPath
method.
More explanation is given in below link
Upvotes: 0
Reputation: 1113
This may help you Show hide table
Or you can use BOOL as a property of cell and hide the subviews of UITableViewCell according to bool also resize frame of cell.
Upvotes: 0