Это UITableView numberOfRowsInSection не вызывает. но cellForRowAtIndexPath не вызывается. Я не понимаю, почему cellForRowAtIndexPath не вызывается. если я Retun номер строки в секцииiOS UITableView cellForRowAtIndexPath не вызывается
return (allOfficedata.count >0)? allOfficedata.count + 1 : allOfficedata.count;
или
return [array count]+1;
if (allOfficedata.count >0) return [allOfficedata count] + 1;
не вызывающей cellforrowatindexpath, если я дать обратный массив рассчитывать; или вернуть 11; его работает отлично Belove я прикрепил мой код, Ошибки
*****, истекающее приложение из-за неперехваченное исключение 'NSRangeException', причина: "* - [__ NSArrayM objectAtIndex]: индекс 10 за пределы [0. . 9]
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView==self.LeftMenuTable)
return leftOptions.count;
return [allOfficedata count]+1;
}
**********************************************************************
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView==self.LeftMenuTable)
return 60;
Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
NSString *checkType = fmodel.achievementType;
if (isPad)
{
if (indexPath.row == 0)
{
return (isPad)?300.0:434.0;
}
else if (indexPath.row == allOfficedata.count+1)
{return 30.0;}
else{
if (![checkType isEqualToString:@""] || [checkType isEqualToString:@"0"] || [checkType isEqualToString:@"1"])
return ([fmodel.feedCommentCount integerValue] > 0)?366:318;
else
return ([fmodel.feedCommentCount integerValue] > 0)?249:200;
}
return 0.0;
}
else
{
if (indexPath.row == 0)
{
return (isPad)?232.0:434.0;
}
else
{
if (![checkType isEqualToString:@""] || [checkType isEqualToString:@"0"] || [checkType isEqualToString:@"1"])
return ([fmodel.feedCommentCount integerValue])?259:222;
else
return ([fmodel.feedCommentCount integerValue])?184:142;
}
return 0.0;
}
}
***************************************************************
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier3 = @"loadMore";
static NSString *CellIdentifier = @"TableViewCell";
if (tableView==self.LeftMenuTable)
{
TableViewCell *cell = (TableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
UIView *sepView=[[UIView alloc ]initWithFrame:CGRectMake(0,59, 250, 1)];
[cell.contentView addSubview:sepView];
[sepView setBackgroundColor:[UIColor grayColor]];
}
cell.cellTextLabel.textColor=[UIColor whiteColor];
[cell.cellTextLabel setText:[[leftOptions objectAtIndex:indexPath.row] valueForKey:@"name"]];
[cell.CellImageView setImage:[UIImage imageNamed:[[leftOptions objectAtIndex:indexPath.row] valueForKey:@"image"]]];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
cell.backgroundColor=[UIColor clearColor];
return cell;
}
else
{
NSUInteger row = [indexPath row];
NSInteger countRoe = [allOfficedata count];
if (row == countRoe)
{
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier3];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier3];
}
cell.textLabel.text = @"LoadMore";
return cell;
}else
{
if (indexPath.row == 0)
{
//CellCallOutBox_Onboarding_iPad
//CellCalloutbox_Office_iPad
//CellCalloutbox_Office_iPhone
NSString *nibName;
if ([calloutOffice.is_empty_daily_mission isEqualToString:@"false"]) {
nibName = (isPad)[email protected]"CellCalloutbox_Office_iPad":@"CellCalloutbox_Office_iPhone";
}
else if ([calloutOffice.is_empty_onboarding_mission isEqualToString:@"false"])
{
nibName = (isPad)[email protected]"CellCallOutBox_Onboarding_iPad":@"CellCallOutBox_Onboarding_iPhone";
}
else if ([calloutOffice.is_empty_community_mission isEqualToString:@"false"])
{
nibName = (isPad)[email protected]"CellCallOutBox_Onboarding_iPad":@"CellCallOutBox_Onboarding_iPhone";
}
CellCalloutbox_Office *cellcallout = (CellCalloutbox_Office *)[tableView dequeueReusableCellWithIdentifier:nibName];
if (cellcallout == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
cellcallout = [nib objectAtIndex:0];
}
cellcallout.aMissionDelegate = self;
[cellcallout.btnVideoOfTheDay addTarget:self action:@selector(videoOfTheDay) forControlEvents:UIControlEventTouchUpInside];
cellcallout.backgroundColor=[UIColor clearColor];
[cellcallout setArraywithCallOut:calloutOffice expanded:isCallOutOfficeExpanded];
[cellcallout.btnBackCallout addTarget:self action:@selector(calloutBack) forControlEvents:UIControlEventTouchUpInside];
[cellcallout.btnDailyMission addTarget:self action:@selector(openCalloutDilyMission) forControlEvents:UIControlEventTouchUpInside];
return cellcallout;
}
Feedmodel *fmodel=[allOfficedata objectAtIndex:indexPath.row];
NSString *checkType = fmodel.achievementType;
if (![checkType isEqualToString:@""] || [checkType isEqualToString:@"0"] || [checkType isEqualToString:@"1"])
{
static NSString *simpleTableIdentifier = @"CellWithImageVideo";
CellWithImageVideo *cell = (CellWithImageVideo *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
NSString *nibNmaeForiPad = (([fmodel.feedCommentCount integerValue])[email protected]"CellWithImage_Comment_iPad":@"Cell_WithImage_MyOffice_iPad");
NSString *nibNmaeForiPhone = (([fmodel.feedCommentCount integerValue])[email protected]"CellWithImagewithComment_iPhone":@"CellWithImageVideo");
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:(isPad)?nibNmaeForiPad:nibNmaeForiPhone owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.backgroundColor=[UIColor clearColor];
cell.contentView.backgroundColor=[UIColor clearColor];
[cell setFeeddata:fmodel indexPath:indexPath];
[cell.hifiveBtn addTarget:self action:@selector(hifiveClickedMyOfiice:) forControlEvents:UIControlEventTouchUpInside];
[cell.playMintBtn addTarget:self action:@selector(getFeedDetails:) forControlEvents:UIControlEventTouchUpInside];
[cell.planToDoBtn addTarget:self action:@selector(planToDoClickedOffice:) forControlEvents:UIControlEventTouchUpInside];
[cell.userImageBtn addTarget:self action:@selector(gotouserProfile:) forControlEvents:UIControlEventTouchUpInside];
[cell.inspireBtn addTarget:self action:@selector(InspireClicked:) forControlEvents:UIControlEventTouchUpInside];
[cell.sendCommentBtn addTarget:self action:@selector(serverCommentPost:) forControlEvents:UIControlEventTouchUpInside];
[cell.btnCompliment addTarget:self action:@selector(getFeedCommentPopup:) forControlEvents:UIControlEventTouchUpInside];
cell.txtFldCommentField.delegate = self;
return cell;
}
else
{
static NSString *simpleTableIdentifier = @"CellWithoutImage";
NSString *nibNmaeForiPad = (([fmodel.feedCommentCount integerValue])[email protected]"Cell_withoutImage_withcomment_iPad":@"Cell_withoutImage_Ipad_Office");
NSString *nibNmaeForiPhone = (([fmodel.feedCommentCount integerValue])[email protected]"CellWithoutImagewithComment_iPhone":@"CellWithoutImage");
CellWithoutImage *cell = (CellWithoutImage *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:(isPad)?nibNmaeForiPad:nibNmaeForiPhone owner:self options:nil];
cell = [nib objectAtIndex:0];
}
[cell setFeeddata:fmodel indexPath:indexPath];
cell.backgroundColor=[UIColor clearColor];
cell.contentView.backgroundColor=[UIColor clearColor];
[cell.hifiveBtn addTarget:self action:@selector(hifiveClickedMyOfiice:) forControlEvents:UIControlEventTouchUpInside];
[cell.planToDoBtn addTarget:self action:@selector(planToDoClickedOffice:) forControlEvents:UIControlEventTouchUpInside];
[cell.userImageBtn addTarget:self action:@selector(gotouserProfile:) forControlEvents:UIControlEventTouchUpInside];
[cell.inspireBtn addTarget:self action:@selector(InspireClicked:) forControlEvents:UIControlEventTouchUpInside];
[cell.btnCompliment addTarget:self action:@selector(getFeedCommentPopup:) forControlEvents:UIControlEventTouchUpInside];
[cell.sendCommentBtn addTarget:self action:@selector(serverCommentPost:) forControlEvents:UIControlEventTouchUpInside];
[cell.btnTextMintTapped addTarget:self action:@selector(getFeedDetails:) forControlEvents:UIControlEventTouchUpInside];
cell.txtFldComment.delegate = self;
return cell;
}
}
}
}
Проверьте значение, возвращаемое в 'numberOfRowsInSection'. –
i 'm return return [allOfficedata count] +1; тот же вопрос –
Я понятия не имею, что значение '[allOfficedata count] + 1', как я могу это знать? –