我想我的一個錶行是一個按鈕,佔用我的UITableView的整行。我認爲最好的方法是實例化一個UIButton,並將它作爲UITableViewCell的實例賦予相同的幀大小,並將其作爲子視圖添加到單元格中。我差不多在那裏,但是有很多像素沒有得到完美的感覺。有沒有更好的方法來解決這個問題,或者可以通過修正我的貼裝精度來獲得完美的對齊方式嗎?UIButton覆蓋UITableViewCell
cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
cell = [self tableviewCellWithReuseIdentifier:CellIdentifier];
}
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:CGRectMake(0.0f, 5.0f, 320.0f, 44.0f)];
[button setTitle:@"Do Stuff" forState:UIControlStateNormal];
[button addTarget:self action:@selector(doStuff:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:button];
您可以在將來將您的問題留下過時的標記「objectivec」嗎?另外,「可可」並不適合iPhone的問題。謝謝! – 2008-12-05 21:42:22