我M個新的,我添加此代碼到定製表格視圖與圖像和按鈕行顯示按鈕
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ImageOnRightCell";
UILabel *mainLabel, *secondLabel;
UIImageView *photo;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 0.0, 100, 20)];
[button addTarget:self action:@selector(buttonPressedAction:) forControlEvents:UIControlEventTouchUpInside];
[button setTag:1];
[cell.contentView addSubview:button];
photo = [[UIImageView alloc] initWithFrame:CGRectMake(50.0, 0.0, 80.0, 45.0)];
photo.tag = PHOTO_TAG;
photo.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:photo];
}
UIImage *theImage = [UIImage imageNamed:@"man.jpg"];
photo.image = theImage;
return cell;
}
圖像部分在表中的行的到來,而不是按鈕。 是什麼,請在它的問題
請修復代碼格式。 –
嘗試給按鈕標題或背景顏色。其實一個自定義單元格是不錯的選擇 – Durgaprasad
問題是與按鈕的框架。部分按鈕位於imageView後面。按鈕150的改變的x座標和看到 –