Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-tableView:cellForRowAtIndexPath: is not getting called

I've UITableView in UIViewController and I've connected through outlet and delegete and datasource are assigned to self.numberOfSectionsInTableView and numberOfRowsInSection are getting called i tried by using NSLogbut cellForRowAtIndexPath is not getting call my code looks like

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

    NSLog(@" cellForRowAtIndexPath ");

    static NSString *CellIdentifier = @"CurrencyCell";

    CurrencyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[CurrencyCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
    }
    new *Obj = [appdelegate.array objectAtIndex:indexPath.row];


    cell.CurNameLabel.text = Obj.C_Name;
    cell.textLabel.text = @"sdfnhsdfndsio;";
    NSLog(@"C_Name %@", Obj.C_Name);

    return cell;
}

can any one tel wer i'm making mistake Thanks in advance

like image 334
Muddu Patil Avatar asked Apr 18 '26 23:04

Muddu Patil


2 Answers

It seems the numberOfSectionsInTableView and numberOfRowsInSection returned are 0.If this is the case then cellForRowAtIndexPath will not get called..

From the comment above..it seems that "YourAppDelegate" variable is null or yourArray is null.Try keeping the break point on these delegates ,to check the values returned by them

like image 136
AppleDelegate Avatar answered Apr 20 '26 16:04

AppleDelegate


try this add delegate and datasource in .h file like below..

@interface AddProjectViewController : UIViewController<
UITableViewDataSource,UITableViewDelegate>
.....
@end

after in viewDidLoad: put this code..

    - (void)viewDidLoad
   {
        yourTableView.delegate= self;
        yourTableView.dataSource=self;
   }

and at last try this in numberOfRowsInSection method to return some int value more than 0

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [yourArray count];//or any int value
}
like image 43
Paras Joshi Avatar answered Apr 20 '26 15:04

Paras Joshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!