小编boo*_*224的帖子

如何调整标签大小以适合文本的长度

我在过去的QAs中搜索了解决方案,但找不到合适的QA.
有谁知道如何UILabel动态调整大小以适应文本长度?
我上传了我不想要的屏幕截图(第1行)和我想要的(第2行).
我很感激任何线索,建议或代码示例.谢谢.在此输入图像描述

objective-c uilabel ios

14
推荐指数
2
解决办法
4万
查看次数

UITableViewCellSelectionStyleNone不起作用

我正在尝试更改所选内容UITableViewCell,但这里发生了一些奇怪的事情.我放了两张图片.请看一下: 在此输入图像描述在此输入图像描述

当我选择"早期"单元格时,它会变为蓝色.它转向'早期的等等' UIViewController.然后当我点击"查找"时UIButton,它会回到第一个视图.它工作,但细胞仍然选择蓝色!所以我写了一些代码如下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    if ([_currentMethod isEqual: @"searchIt"]) {

        if (indexPath.row == 0) {
            BookMark2ViewController* bookMark2 = [[BookMark2ViewController alloc] init];


            UITableViewCell* cell = [self tableView:_tableView
                                            cellForRowAtIndexPath:indexPath];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;



            [self.navigationController pushViewController:bookMark2 animated:YES];

        }else if (indexPath.row == 1) {
            BookMarkViewController* bookMark1 = [[BookMarkViewController alloc] init];

            [self.navigationController pushViewController:bookMark1 animated:YES];

        }
    }
Run Code Online (Sandbox Code Playgroud)

代码中间的两行:

        UITableViewCell* cell = [self tableView:_tableView
                                        cellForRowAtIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
Run Code Online (Sandbox Code Playgroud)

这两行没有用.有谁知道如何解决这一问题?

iphone objective-c uitableview

1
推荐指数
1
解决办法
3709
查看次数

标签 统计

objective-c ×2

ios ×1

iphone ×1

uilabel ×1

uitableview ×1