Reputation: 41
i try many thing but it displaying cells
i have add delegate and datasource tableview.dataSouce =self; tableview.Delegate = self; func cell for row height return 44;
i dont know why table view is not displaying
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
int count = (int)_dict_contact.count;
return count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch (section) {
case 0:
{
NSArray *arr_email =[_dict_contact objectForKey:@"u_email"];
int count = (int)arr_email.count;
return count;
}
break;
case 1:
{
NSArray *arr_phone =[_dict_contact objectForKey:@"u_phone"];
return arr_phone.count;
}
break;
}
return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MultipleContCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell)
{
cell = [[MultipleContCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
switch (indexPath.section) {
case 0:
{
NSArray *arr_email =[_dict_contact objectForKey:@"u_email"];
cell.detail_lbl.text =[arr_email objectAtIndex:indexPath.row];
return cell;
}
break;
case 1:
{
NSArray *arr_phone =[_dict_contact objectForKey:@"u_phone"];
cell.detail_lbl.text =[arr_phone objectAtIndex:indexPath.row];
return cell;
}
break;
}
return cell;
}
but after trying too much then also my cellForRowAtIndexPath not called
Upvotes: 1
Views: 1761
Reputation: 31
Make sure that
Upvotes: 1
Reputation: 145
You need to call registerNib: forCellReuseIdentifier
or registerClass:forCellReuseIdentifier
for MultipleContCell inside viewdidload
. For example:
[_yourTableView registerNib:[UINib nibWithNibName:@"MultipleContCell" bundle:nil] forCellReuseIdentifier:@"MultipleContCell"];
Upvotes: 1
Reputation: 3848
You must declare your ViewController as UITableViewDelegate and UITableViewDataSource. Something like this:
@interface MyViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
Upvotes: 0
Reputation: 3647
Check :
1) The numberOfSectionsInTableView
is not returning 0.
2)UITableview
frame is correct because cellForRowAtIndexPath
would not be called is when the size or positioning of the table does not require any rows to be displayed.
Upvotes: 1