开发者

ReloadData doesn't fire cellForRowAtIndexPath

I know this has been asked over and over again. I've tried all given solution but still it didn't work. I have set the datasource and delegate to my table view and also set it to my pointers.

Here is my code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section     {
NSLog(@"%i", resultSoap.count);
return resultSoap.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell.

NSString *cellValue = [resultSoap objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
NSLog(@"Celldisplay");

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;
}

I've called the reloadData on my viewDidLoad: method. The thing is, it fired numberOfRowsInSection: method and I get 开发者_StackOverflowthe row count correct but it didn't fire this cellForRowAtIndexPath: method.

Any solution?


Use this code:

urtableview.delegate = self;
urtableview.datasource = self;

After declaring the resultsoap array in your code.


It must be due to calling reload method of table when table view datasource array "resultsoap" is empty. Make sure that your datasource array is not empty and check if the array has objects saved.

Because if numberOfRowsInSection returns 0 then the cellForRowAtIndexPath may not be called. And this must be in your case.


Please Add Bellow Code In Your Suitable Methods.

if You had take Simple Controller and Add Table View than

In your Header File .h

#import <UIKit/UIKit.h>
@interface TaskAndTax : UIViewController<UITableViewDelegate, UITableViewDataSource>
{
    IBOutlet UITableView *MyTableView;
}
@property (nonatomic, retain) UITableView *MyTableView;
@end

And in Your .m File

@synthesize MyTableView;

-(void) viewWillAppear:(BOOL)animated
{
  [MyTableView reloadData];
}

And Kindly Connect IBOutlet Of TableView in Our Case its MyTableView to TableView in XIB file.

ReloadData doesn't fire cellForRowAtIndexPath

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜