どのように私は、その後のUITableViewに入れて解析したXMLタグ内の複数の行とテキストのための「復帰文字」を作ることができますか?

StackOverflow https://stackoverflow.com/questions/1880402

質問

私は

のようにUITableViewCellの、テキストで表示したいです

LINE1 LINE2

私はLINE1 LINE2

のようなXMLタグからそれを得ます

私は次のように、多くのことを試してみました: <br/> (also &lt;br&gt;),
\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" に識別子を設定します
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top