Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS 13] UIButton as accessory view in UITableViewCell has wrong frame #693

Closed
ziecho opened this issue Sep 4, 2019 · 1 comment
Closed

Comments

@ziecho
Copy link
Collaborator

ziecho commented Sep 4, 2019

Bug 表现
1、使用 Xcode11 编译 (iOS 13 SDK)
2、将一个带有标题的 UIButton 设置给 UITableViewCell 的 accessoryView,按钮在 cell 中的 frame 错误,而如果没有标题就不会有这个问题

截图
image

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *identifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.backgroundColor = [UIColor lightGrayColor];
        button.bounds = CGRectMake(0, 0, 100, 30);
        
        if (indexPath.row == 1) {
            [button setTitle:@"ButtonTitle" forState:UIControlStateNormal];
        }
        
        cell.accessoryView = button;
    }
    return cell;
}
@ziecho
Copy link
Collaborator Author

ziecho commented Sep 5, 2019

该问题已经在 iOS 13.1 beta2 被苹果修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants