- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [mProfilePostTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
else
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
//self.mProfileImgBtn = [[UIButton alloc]init];
self.mProfileImgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.mProfileImgBtn.userInteractionEnabled = FALSE;
self.mProfileImgBtn.frame = CGRectMake(0, 10, 70, 70);
[self.mProfileImgBtn setBackgroundImage:imgProfile forState:UIControlStateNormal];
[self.mProfileImgBtn addTarget:self action:@selector(noAction) forControlEvents:UIControlEventTouchUpInside];
cellView = [[UIView alloc]init];
cellView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"search_block_big.png"]];
cellView.frame = CGRectMake(65, 10, 245, 140);
self.lblName = [[UILabel alloc]initWithFrame:CGRectMake(85, 20, 100, 20)];
NSString *fName = [self.userProfileResponse valueForKey:@"first_name"];
NSString *lName = [self.userProfileResponse valueForKey:@"last_name"];
NSString *fullName = [NSString stringWithFormat:@"%@ %@", fName, lName];
lblName.backgroundColor = [UIColor clearColor];
lblName.font = [UIFont fontWithName:@"Futura" size:17];
lblName.textColor = [UIColor colorWithRed:120.0/255.0 green:160.0/255.0 blue:48.0/255.0 alpha:1.0];
self.lblName.text = fullName;
self.mLblTime = [[UILabel alloc]initWithFrame:CGRectMake(200, 20, 120, 20)];
self.mLblTime.font = [UIFont fontWithName:@"Futura" size:16];
self.mLblTime.textColor = [UIColor colorWithRed:120.0/255.0 green:160.0/255.0 blue:48.0/255.0 alpha:1.0];
self.mLblTime.backgroundColor = [UIColor clearColor];
self.mLblTime.text = [self.mPostTimeArr objectAtIndex:indexPath.row];
self.mCommentsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.mCommentsBtn.userInteractionEnabled = FALSE;
self.mCommentsBtn.frame = CGRectMake(80, 95, 58, 28);
[self.mCommentsBtn setBackgroundImage:[UIImage imageNamed:@"com_app_.png"] forState:UIControlStateNormal];
[self.mCommentsBtn addTarget:self action:@selector(noAction) forControlEvents:UIControlEventTouchUpInside];
//[self.mCommentsBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
self.mCommentsBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -35, 0, 0);
UILabel *lbl1 = [[UILabel alloc]initWithFrame:CGRectMake(22, 5, 15, 20)];
UILabel *lbl2 = [[UILabel alloc]initWithFrame:CGRectMake(40, 5, 20, 20)];
[self.mCommentsBtn addSubview:lbl1];
[self.mCommentsBtn addSubview:lbl2];
lbl1.text = [self.mCommentsArr objectAtIndex:indexPath.row];
lbl2.text = @"comments";
lbl1.textColor = [UIColor colorWithRed:120.0/255.0 green:160.0/255.0 blue:48.0/255.0 alpha:1.0];
lbl2.textColor = [UIColor colorWithRed:120.0/255.0 green:160.0/255.0 blue:48.0/255.0 alpha:1.0];
NSLog(@"mComm:%@", mCommentsArr);
self.mApplaudsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.mApplaudsBtn.userInteractionEnabled = FALSE;
self.mApplaudsBtn.frame = CGRectMake(143, 95, 58, 28);
[self.mApplaudsBtn setBackgroundImage:[UIImage imageNamed:@"com_app_.png"] forState:UIControlStateNormal];
[self.mApplaudsBtn addTarget:self action:@selector(noAction) forControlEvents:UIControlEventTouchUpInside];
[self.mApplaudsBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
self.mApplaudsBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -15, 0, 0);
//[mApplaudsBtn setTitle:[self.mApplaudsArr objectAtIndex:indexPath.row] forState:UIControlStateNormal];
self.mBoosBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.mBoosBtn.userInteractionEnabled = FALSE;
self.mBoosBtn.frame = CGRectMake(206, 95, 58, 28);
[self.mBoosBtn setBackgroundImage:[UIImage imageNamed:@"com_app_.png"] forState:UIControlStateNormal];
[self.mBoosBtn addTarget:self action:@selector(noAction) forControlEvents:UIControlEventTouchUpInside];
[self.mBoosBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -5)];
self.mBoosBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
//[mBoosBtn setTitle:[self.mBoosArr objectAtIndex:indexPath.row] forState:UIControlStateNormal];
[self performSelector:@selector(btnImage)];
self.mFlagBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.mFlagBtn.userInteractionEnabled = FALSE;
self.mFlagBtn.frame = CGRectMake(270, 95, 33, 28);
[self.mFlagBtn setImage:[UIImage imageNamed:@"flag.png"] forState:UIControlStateNormal];
[self.mFlagBtn addTarget:self action:@selector(noAction) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:self.mProfileImgBtn];
[cell.contentView addSubview:self.cellView];
[cell.contentView addSubview:self.lblName];
[cell.contentView addSubview:self.mCommentsBtn];
[cell.contentView addSubview:self.mApplaudsBtn];
[cell.contentView addSubview:self.mBoosBtn];
[cell.contentView addSubview:self.mFlagBtn];
[cell.contentView addSubview:self.mLblTime];
return cell;
}
这是我从服务器获取的方式:
- (void)callTheServer {
self.userProfileResponse = [FlutterrAPI userDetail:userCredentialsDict];
self.msgShowDict = [FlutterrAPI messagesShow:msgDict];
NSLog(@"msgShowDict:%@", msgShowDict);
[loader removeFromSuperview];
if(mDict != nil)
{
NSArray *commArr = [[NSArray alloc]init];
commArr = [self.mDict valueForKey:@"total_comments"];
//self.mCommentsArr = [[NSMutableArray alloc]initWithArray:commArr];
//[self.mCommentsArr addObject:@"1"];
// [self.mCommentsArr addObject:@"2"];
self.mCommentsArr = [self.mDict valueForKey:@"total_comments"];
self.mApplaudsArr = [self.mDict valueForKey:@"total_applouds"];
self.mBoosArr = [self.mDict valueForKey:@"total_boos"];
self.mPostTimeArr = [self.mDict valueForKey:@"created"];
//self.mImagesArr = [self.mDict valueForKey:@"profile_pic"];
// self.mCommStr = [self.mDict valueForKey:@"total_comments"];
// NSLog(@"mC:%@", self.mCommStr);
NSLog(@"mcomments:%@", mCommentsArr);
NSLog(@"mApp:%@", self.mApplaudsArr);
NSLog(@"mBoos:%@", self.mBoosArr);
NSLog(@"mPoT:%@", self.mPostTimeArr);
//NSLog(@"mI:%@", self.mImagesArr);
}
[self.mProfilePostTableView reloadData];
}
当我提供关于按钮的数据时,它会杀死,检查lbl1。 请指导我出错了什么