0

RSSフィードから取得した記事のタイトルを表す文字列があります。文字列の最後に空白があるので、文字列をトリミングする必要があります。

cell.title.text = [untrimmedTitle stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

ただし、新しい文字列にはタイトル全体が表示されません。たとえば、「最新のパブナイトの妊娠中絶の件名」は「最新」のカットです。

タイトルは通常複数行のUILabelsに保存されますが、タイトルは常に最後から2行目の終わりで切り捨てられることに気付きました。Interface Builderで最大行数を「0」に設定し、改行をワードラップに設定しています。

編集:

これがコードの大部分です。

  NSString *untrimmedTitle = [[stories objectAtIndex: storyIndex] objectForKey: @"title"];
cell.title.text = [untrimmedTitle stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
CGSize maximumLabelSize = CGSizeMake(296,9999);
CGSize expectedLabelSize = [cell.title.text sizeWithFont:cell.title.font constrainedToSize:maximumLabelSize];

//adjust the label to the the new height.
CGRect newFrame = cell.title.frame;
newFrame.size.height = expectedLabelSize.height;
cell.title.frame = newFrame;
4

0 に答える 0