我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];