[英]How to see the whole url in table view
I have some urls in my tableView...What can I do to see not cut urls like: "http://bla-bla-bla.com/bla..."? 我的tableView中有一些网址...该怎么办才能看到未剪切的网址,例如:“ http://bla-bla-bla.com/bla ...”?
I need to see this in my table view: "http://bla-bla-bla.com/bla-bla-bla/bla-bla-bla.png" 我需要在表格视图中看到它:“ http://bla-bla-bla.com/bla-bla-bla/bla-bla-bla.png”
Thank you very much! 非常感谢你!
here is the part of the code, where I input the data: 这是代码的一部分,我在其中输入数据:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"LinkID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
NSData *n = [self.data objectAtIndex:indexPath.row];
[cell.imageView setImageWithURL:[[NSURL alloc]initWithString: [self.data objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:@"placeholder"]];
cell.textLabel.text = [n description];
return cell;
}
One option is to allow the table cell text to resize to fix the text. 一种选择是允许表格单元格文本调整大小以修复文本。
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
cell.textLabel.minimumFontSize = 8; // any smaller and it's too hard to read
}
You may also wish to change the label's lineBreakMode
. 您可能还希望更改标签的
lineBreakMode
。 It may be better to use NSLineBreakByTruncatingMiddle
instead of the default NSLineBreakByTruncatingTail
. 最好使用
NSLineBreakByTruncatingMiddle
而不是默认的NSLineBreakByTruncatingTail
。
Another option might be to setup a multi-line label and use character wrapping for the long URL. 另一个选择可能是设置多行标签,并对长URL使用字符换行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.