Iphone SDK: Tableview tutorials?
I've already done plenty of game-apps and music-apps. However, none of those envolved any use of tableviews. Recently i got a good idea for an app based on tableviews. My problem is: I have 0 tableview knowledge!
If you know some good tableview tutorials, please tell me :). I want to learn everything about tableviews. I also want to know how to use 开发者_JS百科detail-text of a tablecell and how to customize a cell.
Tnanks in advance!
- (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;
}
精彩评论