How To Create Expanding And Collapsing Of Row in UITableView ,
I followed this video ,"https://www.youtube.com/watch?v=OYaI5ASpsOE" after clicked on cell I got following error.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to compare <NSIndexPath: 0x600000029560> {length = 2, path = 0 - 18446744073709551615} with object of different class: NSArray'
Please use This library. Just add it into your project using POD.
pod 'ExpandableCell'
Import it into your viewController
import ExpandableCell
Make ExpandableTableView in Storyboard or in code
#IBOutlet var tableView: ExpandableTableView!
Inherit ExpandableDelegate
class ViewController: UIViewController, ExpandableDelegate
Set delegate
tableView.expandableDelegate = self
Reference: https://github.com/younatics/ExpandableCell
Below tableview delegate and datasource code i used crash is not reproducible to me
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.arrowtitle.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
ExpandingCell *cell = (ExpandingCell *)[tableView dequeueReusableCellWithIdentifier:CELL_IDENTIFIER forIndexPath:indexPath];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:#"Expanding Cell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.lblrow.text = self.arrow[indexPath.row];
cell.lblrowtitle.text = self.arrowtitle[indexPath.row];
cell.lblfruit.text = self.arrFruit[indexPath.row];
NSInteger cal = (indexPath.row) * 25;
cell.lblcalcal.text = [NSString stringWithFormat:#"%ld",(long) cal];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return (self.selectedIndex == indexPath.row) ? 120 : 45 ;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (self.selectedIndex == indexPath.row) {
self.selectedIndex = -1;
[tableView reloadRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationFade];
return;
}
if (self.selectedIndex == -1) {
NSIndexPath *prev = [NSIndexPath indexPathForRow:self.selectedIndex inSection:0];
self.selectedIndex = indexPath.row;
[tableView reloadRowsAtIndexPaths:#[prev] withRowAnimation:UITableViewRowAnimationFade];
}
self.selectedIndex = indexPath.row;
[tableView reloadRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
Related
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView registerNib:[UINib nibWithNibName:#"FriendTableViewCell" bundle:nil] forCellReuseIdentifier:#"FIDCELL"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
FriendTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"FIDCELL"];
return cell;
}
This code block work but when i add new cell in FriendTableViewCell.xib not work actually i can not call new cell. How can i call this cell or this is possible ? If this question is not clear i can add image...
**
i try to call different cell from same .xib
**
Error:
I found solution i generate new .xib and call when page load both of them
[self.tableView registerNib:[UINib nibWithNibName:#"FriendTableViewCell" bundle:nil] forCellReuseIdentifier:#"FIDCELL"];
[self.tableView registerNib:[UINib nibWithNibName:#"Cell2" bundle:nil] forCellReuseIdentifier:#"FIDCELL2"];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellID = #"";
if (indexPath.row % 2 == 0) {
cellID = #"FIDCELL";
} else {
cellID = #"FIDCELL2";
}
FriendTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
// Configure the cell...
cell.nameLabel.text = self.namesArray[indexPath.row];
cell.photoImageView.image = [UIImage imageNamed:self.photoNameArray[indexPath.row]];
return cell;
}
This code part totally work.
Okey so first of all , every cell should have its unique identifier so if the first cell have an identifier called "FIDCELL" the second one should have another one called "FIDCELL2" for example , and remove the following line from your viewDidLoad :
[self.tableView registerNib:[UINib nibWithNibName:#"FriendTableViewCell" bundle:nil] forCellReuseIdentifier:#"FIDCELL"];
and add this to cellForRowAtIndexPath
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomTableViewCell * cell ;
if(condtion1)
{
cell = [tableView dequeueReusableCellWithIdentifier:firstCellIdentfier];
}
else if(condtion2)
{
cell = [tableView dequeueReusableCellWithIdentifier:secondCellIdentfier];
}
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:yourNibName owner:self options:nil];
if(condtion1)
{
//0 is the index of the first cell in the nib
cell = [nib objectAtIndex:0];
}
else if(condtion2)
{
//1 is the index of the second cell in the nib .
cell = [nib objectAtIndex:1] ;
}
}
//do other work
return cell ;
}
where condtion1 and and condtion2 is the conditions that will determine which cell will be chosen .
I have a UITableView call myTableView with two custom UITableViewCell call TableViewCell & ExTableViewCell. What I want is, when user tap on a cell, the existing cell TableViewCell will hide/move and ExTableViewCell is loaded in that indexpath.row and when tap on that indexpath.row again it hide ExTableViewCell and bring back the old TableViewCell in that position.
Here is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.myArray = [[NSArray alloc] initWithObjects:#"one", #"two", #"three", #"four", #"five", #"six", nil];
selectedIndex = -1;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (selectedIndex == indexPath.row)
{
return 230;
}
else
{
return 40;
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.myArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
TableViewCell *Cell = (TableViewCell *)[self.myTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!Cell)
{
Cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Cell.myLabel.text = [self.myArray objectAtIndex:indexPath.row];
if (selectedIndex == indexPath.row)
{
static NSString *CellIdentifier = #"CellEx";
ExTableViewCell *Cell = (ExTableViewCell *)[self.myTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!Cell)
{
Cell = [[ExTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Cell.backgroundColor = [UIColor redColor];
Cell.exLabel.text = [self.myArray objectAtIndex:indexPath.row];
}
else
{
// Do close cell stuff
//Cell.backgroundColor = [UIColor clearColor];
}
return Cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Expand row when user taps row
if (selectedIndex == indexPath.row)
{
selectedIndex = -1;
[self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationFade];
return;
}
// When user taps different row
if (selectedIndex != -1)
{
NSIndexPath *prevPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
selectedIndex = indexPath.row;
[self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:prevPath] withRowAnimation:UITableViewRowAnimationFade];
}
// When user taps new row with none expanded
selectedIndex = indexPath.row;
[self.myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
But for some reason in the ExTableViewCell label is not showing any text. And the ExTableViewCell is still top of it. How can I achieve this?
A lot a thanks for advance. Have a good day. :)
This is the out put:
My problem:
You don't need to 'hide' the old cell in order to show the new one, you just reload the proper content at the desired index path. Something like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell" forIndexPath:indexPath];
if ([self.selectedPath isEqual:indexPath]) {
//configure the extended cell
cell = [tableView dequeueReusableCellWithIdentifier:#"CellEx" forIndexPath:indexPath];
...
} else {
//configure the default cell
}
}
And here is how to handle the selected/deselected state:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSIndexPath *oldPath = [self.selectedPath copy];
self.selectedPath = indexPath;
NSArray *paths = #[indexPath];
if (oldPath && ![oldPath isEqual:indexPath]) {
paths = [paths arrayByAddingObject:oldPath];
} else if ([oldPath isEqual:indexPath]){
self.selectedPath = nil;
}
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
}
I have two custom cells. And I want to display 2 sections in my UITableView. The first section with one row displaying the first custom cell, and the second section displaying a list of objects pulled from core data.
How should I implement the "cellForRowAtIndexpath" method ?
Here is some of my code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
if (section == 0) {
return 1;
} else if (section == 1) {
//gastos is an array
return [self.gastos count];
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
case 0:
{
SaldoCelda *cell1 = [tableView dequeueReusableCellWithIdentifier:#"Cell1" forIndexPath:indexPath];
return cell1;
}
case 1:
{
static NSString *CellIdentifier = #"Cell";
CeldaGasto *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSManagedObject *gasto = [self.gastos objectAtIndex:indexPath.row];
[cell.monto setText:[NSString stringWithFormat:#"%# AR$", [gasto valueForKey:#"monto"]]];
[cell.categoria setText:[NSString stringWithFormat:#"%#", [gasto valueForKey:#"categoria"]]];
[cell.fecha setText:[NSString stringWithFormat:#"%#", [gasto valueForKey:#"fecha"]]];
return cell;
}
default:
break;
}
return 0;
}
And this is the error message I get:
Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.23/UITableView.m:6246
2014-03-05 01:02:57.181 Spendings[2897:70b] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
Thankyou for your help!
I have made a test and it works fine. These are the steps:
Create UITableViewController in storyBoard
Drag and drop UITableViewCell on a UITableViewController below the cell that is already there
Assign CellIdentifier to both cells (I used Cell1 and Cell2)
Create 2 subclasses of UITableViewCell (I called them Cell1 and Cell2)
Create subclass of UITableViewController and name it somehow
in cellForRowAtIndexPath method:
static NSString *CellIdentifier = #"Cell1";
static NSString *CellIdentifier1 = #"Cell2";
switch (indexPath.section) {
case 0:
{
Cell1 *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
return cell;
}
break;
case 1:
{
Cell2 *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1 forIndexPath:indexPath];
return cell;
}
break;
default:
break;
}
return nil;
As you can see the implementation is the same as yours
The only way I could reproduce your error is by returning nil in switch block and the documentation for dequeueReusableCellWithIdentifier says:
This method always returns a valid cell.
Even if you messed up your cell identifiers, you still wouldn't get the error you posted. So my conclusion is:
reboot, clean project, restart simulator or something like that cause your scenario according to documentation is not possible...
Beside you are returning nil for one of your cells, you also has an issue in numberOfRowsInSection, you are returning 0 rows for section 1!!, although you are expecting rows in this section in your cellForRowAtIndexPath.
you can create set of cell in one xib and fetch it in cellForRowAtindex with it's identifier. Now you can set it's property and data to it.
static NSString *CellIdentifier = #"MyCellIdentifier";
MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
cell = (MyCell *)[nib objectAtIndex:0];
cell1=(MyCell *)[nib objectAtIndex:1];
}
Try This i'm modifying your code
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
if (section == 0) {
return 1;
}
else if (section == 2) {
//gastos is an array
return [self.gastos count];
}
//return 0; you should not write this because at the end of execution of this method it will return 0
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
switch (indexPath.section) {
case 0:
{
SaldoCelda *cell1 = [tableView dequeueReusableCellWithIdentifier:#"Cell1" forIndexPath:indexPath];
cell=cell1;
break;
}
case 1:
{
static NSString *CellIdentifier = #"Cell";
CeldaGasto *cell2 = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSManagedObject *gasto = [self.gastos objectAtIndex:indexPath.row];
[cell.monto setText:[NSString stringWithFormat:#"%# AR$", [gasto valueForKey:#"monto"]]];
[cell.categoria setText:[NSString stringWithFormat:#"%#", [gasto valueForKey:#"categoria"]]];
[cell.fecha setText:[NSString stringWithFormat:#"%#", [gasto valueForKey:#"fecha"]]];
cell=cell2;
break;
}
default:
break;
}
return cell;
//return 0; remove this in your code
}
Hope this will help
I'm trying to add custom cells to a static UITableViewController. I use SWTableViewCell to get the swipable cell and I'm using a custom -xib for the cell layout.
I seems to work fine when I only need to use one cell, but when there are more then one I get this: Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
This happens when I use dequeueReusableCellWithIdentifier in the cellForRowAtIndexPath when the second cell should appear (when I begin to scroll).
Here is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.images = selectedReport.image;
imagesArray = [self.images.allObjects mutableCopy];
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
[self.tableView registerNib:[UINib nibWithNibName:#"PictureCell" bundle:nil] forCellReuseIdentifier:#"PictureCell"];
}
- (NSInteger) tableView:(UITableView *) tableView numberOfRowsInSection:(NSInteger) section
{
if(section == 0){
return 10;
}else if(section == 1){
return imagesArray.count; //It is the second section which is dynamic
}
return 1;
}
- (UITableViewCell *) tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath
{
static NSString* cellIdentifier = #"PictureCell";
if (indexPath.section == 0 || indexPath.section == 2)
{ //Takes the rows from the storyboard
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
}
else
{
NSLog(#"%i",indexPath.row);
NSLog(#"%i",indexPath.section);
PictureTableViewCell *cell = (PictureTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; //Crash here when indexPath.row == 1
[cell setCellHeight:cell.frame.size.height];
cell.containingTableView = tableView;
indexPath.section, indexPath.row];
Image *tempImage = imagesArray[indexPath.row];
cell.image.image = [UIImage imageWithData:tempImage.image];
cell.lblDescription.text = tempImage.image_description;
cell.rightUtilityButtons = [self rightButtons];
cell.delegate = self;
return cell;
}
}
I have checked that numberOfRowsInSection returns 2 when section == 1.
Thank you for any assistance!
Use this instead
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
or in viewDidLoad, register the class like
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:#"PictureCell"];
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"PictureCell" forIndexPath:indexPath];
}
Suppose there is Custom Cell A & B of different Height.
Custom Cell A is loaded Default on UITableView. When User will Select Cell A it will remove that Cell and Add Cell B to that Position and vise versa. It will do the animation of re-sizing in Accordion style.
To do this, you should have a property (or key if using a dictionary) in your data array to keep track of what cell you want at each indexPath, and use an if-else statement in cellFroRowAtIndexPath to dequeue the correct cell. In didSelectRowAtIndexPath, you would check that property, set it to the opposite one, and then reload the table. You would also need to implement heightForRowAtIndexPath, and check that same property to determine which height to return.
After Edit:
If you just need to keep track of one selected cell, then create a property (I call it selectedPath) to hold that value and check it in heightForRowAtIndexPath and cellForRowAtIndexPath. I created two cells in the storyboard, one a simple UITableViewCell and the other a custom cell of class RDCell. I'm not sure if this gives the animation you want, but give it a try and see if it's close:
#import "TableController.h"
#import "RDCell.h"
#interface TableController ()
#property (strong,nonatomic) NSArray *theData;
#property (nonatomic) NSIndexPath *selectedPath;
#end
#implementation TableController
- (void)viewDidLoad {
[super viewDidLoad];
self.theData = #[#"One",#"Two",#"Three",#"Four",#"Five",#"Six",#"Seven",#"Eight"];
self.selectedPath = [NSIndexPath indexPathForRow:-1 inSection:0];
[self.tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.theData.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.selectedPath isEqual:indexPath]) {
return 90;
}else{
return 44;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.selectedPath isEqual:indexPath]) {
RDCell *cell = [tableView dequeueReusableCellWithIdentifier:#"RDCell" forIndexPath:indexPath];
cell.label.text = self.theData[indexPath.row];
return cell;
}else{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell" forIndexPath:indexPath];
cell.textLabel.text = self.theData[indexPath.row];
return cell;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSIndexPath *oldPath = self.selectedPath;
self.selectedPath = indexPath;
[self.tableView reloadRowsAtIndexPaths:#[indexPath,oldPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
**Got this amazing Solution, its working great...**
#implementation NetworkCentreTable
{
NSMutableArray *arr;
BOOL chk;
int onSelectCount;
NSIndexPath *onSelectTrack;
}
- (void)viewDidLoad
{
[super viewDidLoad];
arr=[[NSMutableArray alloc] initWithObjects:#"1",#"1",#"1",#"1",#"1",#"1",#"1",#"1",#"1",nil];
onSelectCount=0;
static NSString *CellIdentifier1 = #"NetworkCell2";
UINib *nib = [UINib nibWithNibName:#"NetworkCentreCellBig" bundle:nil];
[self.tblNetworkCentre registerNib:nib forCellReuseIdentifier:CellIdentifier1];
}
#pragma mark -
#pragma mark Custom Network TableView delegate and Datasource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [arr count];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier1 = #"NetworkCentreCell";
static NSString *CellIdentifier2 = #"NetworkCentreCellBig";
if(self.selectedRowIndex && indexPath.row == self.selectedRowIndex.integerValue)
{
NetworkCentreCell *cell = (NetworkCentreCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
UIViewController *controller=[[UIViewController alloc] initWithNibName:CellIdentifier2 bundle:nil];
cell=(NetworkCentreCell *)controller.view;
return cell;
}
else
{
NetworkCentreCell *cell = (NetworkCentreCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
UIViewController *controller=[[UIViewController alloc] initWithNibName:CellIdentifier1 bundle:nil];
cell=(NetworkCentreCell *)controller.view;
return cell;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
onSelectCount++;
NSLog(#"num=%d",onSelectCount);
self.selectedIndexPath = indexPath;
[tableView reloadRowsAtIndexPaths:#[indexPath] withRowAnimation: UITableViewRowAnimationNone];
self.selectedRowIndex = [NSNumber numberWithInteger:indexPath.row];
[self.tblNetworkCentre deselectRowAtIndexPath:indexPath animated:YES];
//First we check if a cell is already expanded.
//If it is we want to minimize make sure it is reloaded to minimize it back
if( onSelectCount==1 )
{
[tableView beginUpdates];
NSIndexPath *previousPath = [NSIndexPath indexPathForRow:self.selectedRowIndex.integerValue inSection:0];
self.selectedRowIndex = [NSNumber numberWithInteger:indexPath.row];
onSelectTrack=indexPath;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:previousPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
}
if(onSelectTrack.row!=indexPath.row)
{
[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:onSelectTrack] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
onSelectTrack=indexPath;
onSelectCount=0;
[self tableView:tableView didSelectRowAtIndexPath:onSelectTrack];
}
if(self.selectedRowIndex.integerValue == indexPath.row && onSelectCount==2)
{
[tableView beginUpdates];
self.selectedRowIndex = [NSNumber numberWithInteger:-1];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
onSelectCount=0;
[tableView endUpdates];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if(self.selectedRowIndex && indexPath.row == self.selectedRowIndex.integerValue)
{
return 280;
}else{
return 85;
}
}
You can call [yourTableview reloadData] in didSelectRowAtIndexPath method.
Then in numberOfRowsInSection give a new count. In heightForRowAtIndexpath specify the custom heights.
In cellForRowAtIndexpath add custom cells.