1

ここに画像の説明を入力iPhoneアプリケーションで約16,000行のテキストを表示するためのUILabelを作成しています.ios 6までは正常に動作していましたが、ios 6.0以降では正しく表示されません。

ラベルに何も表示されません。以前は正常に機能していましたが、何が問題なのかわかりません。Scrollview に UILabel を追加しました。ラベルのコードは以下のとおりです:=

infoUILabel.text = stringForLargeDescrition;
CGSize constraintSize;
    constraintSize.width = 285.0f;
    constraintSize.height = MAXFLOAT;

stringSizeforDescription = [strignForLabel sizeWithFont: [UIFont boldSystemFontOfSize: 5] constrainedToSize: constraintSize lineBreakMode: UILineBreakModeWordWrap];
        infoUILabel.layer.cornerRadius = 10;    
        infoUILabel.layer.masksToBounds = YES;
        [infoUILabel setFrame:CGRectMake(20,135, 285, stringSizeforDescription.height)];
        CGRect frame = infoUILabel.frame;
        frame.size = [infoUILabel sizeThatFits:CGSizeMake(285, stringSizeforDescription.height)];
        infoUILabel.frame = frame;
        [infoUILabel alignTop];//this function will align the text to top of label
         backScrollView.contentSize = CGSizeMake(320, 230 + infoUILabel.frame.size.height);
     backScrollView.clipsToBounds = YES;

提案してください、事前に感謝します。

4

5 に答える 5

2

動的テキストを表示するtextviewを使用すると、問題が解決しました。コードは次のとおりです。

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 135, 285, 200)];
    textView.text = @"Very large text";
    textView.scrollEnabled = NO;
    textView.delegate = self;
    textView.font = [UIFont fontWithName:@"Helvetica" size:12.0f];
    textView.textColor = [UIColor darkGrayColor];
    textView.layer.cornerRadius = 10;
    textView.layer.masksToBounds = YES;
    textView.backgroundColor= [UIColor whiteColor];
    CGRect rect      = textView.frame;

 CGSize constraintSize;
constraintSize.width = 285.0f;
constraintSize.height = MAXFLOAT;
stringSizeforDescription = [strignForLabel sizeWithFont: [UIFont boldSystemFontOfSize: 12] constrainedToSize: constraintSize lineBreakMode: UILineBreakModeWordWrap];
    rect.size.height = stringSizeforDescription.height + 20;//20 is some extra margin value 
    textView.frame   = rect;

[scrollView addSubview:textView];
[textView sizeToFit];
于 2013-03-12T11:50:30.797 に答える
0

これを試してみてください:

CGFloat height = 44.0;

CGSize labelSize = CGSizeMake(200.0, 20.0);

NSString *strTemp;

NSString *sectionData = @"Lengthy text.......Lengthy text.......Lengthy text.......";

labelSize = [sectionData sizeWithFont: [UIFont boldSystemFontOfSize:12.0] constrainedToSize: CGSizeMake(labelSize.width, 1000) lineBreakMode: UILineBreakModeWordWrap];

height =  (labelSize.height+40);

CGRect rect = lbl.frame;

rect.size.height = height;

lbl.frame = rect;
于 2013-02-28T08:19:07.097 に答える
0

設定する numberOfLines プロパティがありません。

追加 :

infoUILabel.numberOfLines = 0;

それはうまくいくはずです。また、コードから次の 2 行を削除します。

frame.size = [infoUILabel sizeThatFits:CGSizeMake(285, stringSizeforDescription.height)];
infoUILabel.frame = frame;
于 2013-02-28T05:59:56.297 に答える
-1

追加

infoLabel.numberOfLines=0;

MAXFLOAT の値が予想よりも大きいことを確認してください

于 2013-02-28T06:05:53.083 に答える
-1

UILabel のすべてのプロパティを設定した後、最後にテキストを UILabel に設定してみてください。

于 2013-02-28T07:32:17.187 に答える