I have some urls in my tableView...What can I do to see not cut urls like: "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"
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
. It may be better to use NSLineBreakByTruncatingMiddle
instead of the default NSLineBreakByTruncatingTail
.
Another option might be to setup a multi-line label and use character wrapping for the long URL.
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.