我已经完成了很多游戏应用和音乐应用。但是,这些都没有涉及任何tableviews的使用。最近我对基于tableviews的应用程序有个好主意。我的问题是:我有0个tableview知识!
如果你知道一些很好的tableview教程,请告诉我:)。我想学习有关tableviews的一切。我还想知道如何使用tablecell的详细文本以及如何自定义单元格。
提前Tnanks!
答案 0 :(得分:-1)
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return arr_finallistoffb.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"WhispersCell";
WhispersCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[WhispersCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.textColor = [UIColor darkGrayColor];
}
int cellheight;
NSString *str_question=[NSString stringWithFormat:@"Status: %@",[resultArray objectAtIndex:indexPath.row]];
UIFont *font_question = [UIFont fontWithName:@"Gotham-Medium" size:14.0];
CGSize size12312 = [(str_question ? str_question : @"") sizeWithFont:font_question constrainedToSize:CGSizeMake(260.0f, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
cellheight=size12312.height+35;
NSString *str_answer=[NSString stringWithFormat:@"Status: %@",[arr_Answer_filters objectAtIndex:indexPath.row]];
UIFont *font = [UIFont fontWithName:@"Gotham-Medium" size:14.0];
CGSize size = [(str_answer ? str_answer : @"") sizeWithFont:font constrainedToSize:CGSizeMake(260.0f, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
cellheight=cellheight+size.height+20;
if ([[[arr_finallistoffb objectAtIndex:indexPath.row]valueForKey:@"int_id"] isEqualToString:[[NSUserDefaults standardUserDefaults] valueForKey:PREF_USER_ID]])
{
cell.btn_CommentIcon.userInteractionEnabled=NO;
cell.plusbtnOutlet.userInteractionEnabled=NO;
}
else
{
cell.btn_CommentIcon.userInteractionEnabled=YES;
cell.plusbtnOutlet.userInteractionEnabled=YES;
}
cell.img_users.layer.borderWidth=3.0;
cell.img_users.layer.cornerRadius=cell.img_users.frame.size.height/2;
cell.lbl_UserName.text=[NSString stringWithFormat:@"%@",[[arr_finallistoffb objectAtIndex:indexPath.row] objectForKey:@"var_username"]];
[cell.img_users.layer setBorderColor: [[UIColor colorWithRed:(12.0/255.0) green:(14.0/255.0) blue:(41.0/255.0) alpha:1.0] CGColor]];
cell.img_users.layer.masksToBounds=YES;
[cell.img_users setImageWithURL:[APPDELEGATE getURLForMediumSizeImage:[[arr_finallistoffb objectAtIndex:indexPath.row]valueForKey:@"var_img"]] placeholderImage:[UIImage imageNamed:@"logoinofficiel"] usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
cell.plusbtnOutlet.tag=indexPath.row;
[cell.plusbtnOutlet addTarget:self action:@selector(btn_add_culturellis:) forControlEvents:UIControlEventTouchUpInside];
if ([[[arr_finallistoffb objectAtIndex:indexPath.row]valueForKey:@"is_follower"]integerValue]==1)
{
[cell.plusbtnOutlet setSelected:YES];
}
else{
[cell.plusbtnOutlet setSelected:NO];
}
[cell.button_userselection addTarget:self action:@selector(btn_User_culturellis:) forControlEvents:UIControlEventTouchUpInside];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"Overview_Register"])
{
WDRegisterViewController *obj=(WDRegisterViewController *)[segue destinationViewController];
obj.str_Title=@"Edit Profile";
obj.isRegister=NO;
}
}
[self performSegueWithIdentifier:@"Overview_Measure" sender:nil];
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
WDPeekViewController *Peek = (WDPeekViewController *)[sb instantiateViewControllerWithIdentifier:@"WDPeekViewController"];
[self.navigationController pushViewController:tabBarController animated:YES];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;
}