Я делаю модуль входящей почты в своем приложении. Сначала загружается 20 сообщений с сервера. Я хочу, чтобы после 20 сообщений в ячейке UItableview создавалась метка с именем «загрузить больше сообщений». и после нажатия на эту метку я хочу сделать еще один звонок на сервер. Я пробовал следующий код, но он не работает. спасибо заранее :( ниже мой пример кода cellForRowAtIndexPath и numberOfRowsInSectionсоздать действие метки пользовательского интерфейса в tableviewcell
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [inboxmessagesarray count]+1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *tableviewidentifier = @"cell";
__block tablecellTableViewCell *cell= [self.activitiesTableView_ dequeueReusableCellWithIdentifier:tableviewidentifier];
if(cell==nil)
{
cell = [[tablecellTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableviewidentifier];
}if(indexPath.row == [self tableView:self.activitiesTableView_ numberOfRowsInSection:indexPath.section] - 1){
[email protected]"Load More Record";// here i am making a label but it is not showing at the end of tableview cell
}
else{
__block NSString *row = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
cell.titlename.font=[UIFont fontWithName:@"SegoeUI" size:15];
cell.tolbl.font=[UIFont fontWithName:@"SegoeUI-light" size:12];
cell.fromlbl.font=[UIFont fontWithName:@"SegoeUI-light" size:12];
cell.datelbl.font=[UIFont fontWithName:@"SegoeUI-light" size:8];
cell.timelbl.font=[UIFont fontWithName:@"SegoeUI-light" size:8];
if([[[self.inboxmessagesarray objectAtIndex:indexPath.row]objectForKey:@"messageRead"] intValue]==0)
{
cell.titlename.font=[UIFont fontWithName:@"SegoeUI" size:15];
cell.tolbl.font=[UIFont fontWithName:@"SegoeUI-light" size:12];
cell.fromlbl.font=[UIFont fontWithName:@"SegoeUI-light" size:12];
cell.datelbl.font=[UIFont fontWithName:@"SegoeUI-light" size:8];
cell.timelbl.font=[UIFont fontWithName:@"SegoeUI-light" size:8];
cell.contentView.backgroundColor=[UIColor lightGrayColor];
}
else
{
cell.titlename.font=[UIFont fontWithName:@"SegoeUI" size:15];
cell.tolbl.font=[UIFont fontWithName:@"SegoeUI-light" size:12];
cell.fromlbl.font=[UIFont fontWithName:@"SegoeUI-light" size:12];
cell.datelbl.font=[UIFont fontWithName:@"SegoeUI-light" size:8];
cell.timelbl.font=[UIFont fontWithName:@"SegoeUI-light" size:8];
cell.contentView.backgroundColor=[UIColor clearColor];
}
cell.titlename.text=[[self.inboxmessagesarray objectAtIndex:indexPath.row]objectForKey:@"offerTitle"];
//toCity
cell.tolbl.text=[[self.inboxmessagesarray objectAtIndex:indexPath.row]objectForKey:@"toCity"];
cell.fromlbl.text=[[self.inboxmessagesarray objectAtIndex:indexPath.row]objectForKey:@"fromCity"];
if(![[imagesDictionary allKeys] containsObject:row]) //if image not found download and add it to dictionary
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSString *img=[[self.inboxmessagesarray objectAtIndex:indexPath.row]objectForKey:@"offerPhoto"];// here i am getting image path
NSURL *url = [NSURL URLWithString:img];
NSData * imageData = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:imageData];
dispatch_sync(dispatch_get_main_queue(), ^{ //in main thread update the image
[imagesDictionary setObject:image forKey:row];
cell.profileimage.image = image;
cell.textLabel.text = @""; //add this update will reflect the changes
NSLog(@"loading and adding to dictionary");
});
});
}
else
{
cell.profileimage.image = [imagesDictionary objectForKey:row];
NSLog(@"retriving from dictionary");
}
cell.datelbl.text=[[self.inboxmessagesarray objectAtIndex:indexPath.row]objectForKey:@"messageDate"];
cell.timelbl.text=[[self.inboxmessagesarray objectAtIndex:indexPath.row]objectForKey:@"messageTime"];
}
return cell;
}
вам нужно добавить жест нажатия на ярлык. после этого вы сможете выполнить действие (делать то, что вам нужно в методе calback) –
ярлык не отображается правильно ...u может прочитать мой полный вопрос ' –
и, пожалуйста, также скриншот, я хочу показать эту метку или кнопку в конце сообщений, когда сообщения были загружены после того, как я муравью показать –