简体   繁体   中英

Problem with Custom accessoryView in UITableView

I have two table views with the following declarations.

cAboutUs = [[UITableView alloc] initWithFrame:CGRectMake(85, 272, 227, 30)];

ctableView = [[UITableView alloc] initWithFrame:CGRectMake(85, 302, 227, 100)];    

when i try to add a custom accessory view using the below code, both comes at different locations in cell. (in cAboutUs it is more towards left(x) when compared to the ctableView cell accessory)

UIImage *image = [UIImage imageNamed:@"bullet.png"];

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
button.frame = frame;

[button setBackgroundImage:image forState:UIControlStateNormal];
cell.accessoryView = button;

I tried the same by using the

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator

it shows properly with well aligned.

Please help me in solving the bug.

它通过将cAboutUs表单元格的高度增加到40来解决。这很奇怪,但是没有理由解决。

Check the height for the cells in the two table views.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
// Make sure height for the cells is the same
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM