我有一個UITableView
,每個單元格前面都有一個圖像按鈕,我想調整該UIButton
的座標。寫入cellForRow
相關的代碼如下:更改表格視圖單元格中的圖像按鈕的位置
UIImage *image = [UIImage imageNamed "unchecked.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame1 = CGRectMake(0.0,0.0, image.size.width, image.size.height);** //changing the coordinates here doesn't have any effect on the position of the image button.
button.frame = frame1; // match the button's size with the image size
[button setBackgroundImage:image forState:UIControlStateNormal]; // set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet [button addTarget :self action: @selector(checkButtonTapped:event) forControlEvents:UIControlEventTouchUpInside];
那不是相關的代碼相關的代碼是你是否正確處理tableview單元格緩存。 –
編寫完整的cellForRowAtIndexPath方法 –
您要添加按鈕的位置? – DivineDesert