각 셀 앞에 이미지 단추가있는 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];
관련 코드는 관련 코드가 테이블 뷰 셀 캐싱을 제대로 처리했는지 여부입니다. –
전체 cellForRowAtIndexPath 메소드를 작성하시오. –
버튼을 어디에서 추가하고 있습니까? – DivineDesert