私はUIのtableViewを持っていると私は履歴のクリアにSafariの設定で使用されているようなボタンを作成しようとしています:は、テーブルビューのセルにボタンを追加します。
私が試してみましたコードをdoesntのは、本当に仕事と私はより良い方法があると確信している:
case(2):
// cell = [[[ButtonLikeCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if (indexPath.row == 0)
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:cell.bounds];
[button addTarget:self action:@selector(clearButtonClick) forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundColor:[UIColor purpleColor]];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setTitle:@"Clear Data" forState:UIControlStateNormal];
cell.accessoryView = nil;
cell.clipsToBounds=YES;
[cell.contentView addSubview:button];
}
break;
}
}
return(cell);
}
あなたは正しいです! textLabelがsizeToFitを通過するような印象にあったので、位置合わせを変更しても機能しません。 –