我在过去的QAs中搜索了解决方案,但找不到合适的QA.
有谁知道如何UILabel
动态调整大小以适应文本长度?
我上传了我不想要的屏幕截图(第1行)和我想要的(第2行).
我很感激任何线索,建议或代码示例.谢谢.
我正在尝试更改所选内容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)
这两行没有用.有谁知道如何解决这一问题?