UItableViewCellに表示したい、テキストのように
ライン1 ライン2
line1 line2 のようなxmlタグから取得します
私は多くのことを試しました:
<br/> (also <br>),
\n which only displays "line1 \n line2",
<![CDATA[<br >]]> which only displays "line1 <br> line2".
助けてくれてありがとう
UItableViewCellに表示したい、テキストのように
ライン1 ライン2
line1 line2 のようなxmlタグから取得します
私は多くのことを試しました:
<br/> (also <br>),
\n which only displays "line1 \n line2",
<![CDATA[<br >]]> which only displays "line1 <br> line2".
助けてくれてありがとう
次のようなテキストを設定していますcell.textLabel.text = myText
か?
その場合、UILabel に送信していますが、UILabels に改行を含めることはできません。あなたが試すことができるのは、UITextView を使用してカスタム セルを作成し、そこにテキストを送信することです。
カスタム セルの例: テーブルビュー クラス:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"quickListViewCell";
quickListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"quickListViewCell" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[quickListViewCell class]])
{
cell = (quickListViewCell *)currentObject;
break;
}
}
}
[[cell textFieldText] setText:@"Line 1 \n Line 2"];
return cell;
}
quickListViewCell.h
#import <UIKit/UIKit.h>
@interface appCountryCategoryViewCell : UITableViewCell {
IBOutlet UITextView *textFieldText;
}
@property (nonatomic, retain) IBOutlet UITextView *textFieldText;
@end
quickListViewCell.m
#import "quickListViewCell.h"
@implementation quickListViewCell
@synthesize textFieldText;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)dealloc {
[super dealloc];
}
@end
IB で UITableViewCell を作成し、識別子を「quickListViewCell」に設定します。