0

I am trying to make a book application. I am stucked with the text that can show long string. Basically, I tried to use UI Label, but it is only showing one line and the remaining of the text is cut.

Any idea what kind of UI that I should use to make a book? Thanks.

4

2 回答 2

1

将 UILabel 的numberOfLines设置为 0,让它根据需要使用尽可能多的行。

于 2013-07-07T17:56:23.040 回答
0

您必须使用 UITextView 进行此类检查

UITextView *aboutStable = [[UITextView alloc] init];
[aboutStable setFont:[UIFont fontWithName:@"Helvetica" size:12]];
[aboutStable setText:@"Write your long text here............iphonemaclover is great"];
[aboutStable setTextColor:[UIColor grayColor]];
[aboutStable setBackgroundColor:[UIColor clearColor]];
[aboutStable setTextAlignment:UITextAlignmentCenter];
[aboutStable setFrame:CGRectMake(0, 302, 320, 79)];
[self addSubview:aboutStable];

并使其不可编辑所以设置

[aboutStable setUserInteractionEnabled:NO] 应该这样做

如果您需要滚动:

aboutStable.editable = NO;

或者如果你的文字更多,那么你也可以在其中设置滚动视图......

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 195, 280, 10)];
textView.text = @"your long text here";
textView.font = [UIFont fontWithName:@"Hevlatica" size:14];
[self.scrollView addSubview:textView];//add scrollview using Xib and set property of it.
CGRect descriptionFrame = textView.frame;
descriptionFrame.size.height = textView.contentSize.height;
textView.frame = descriptionFrame;

或者您可以在此示例代码中查看更多详细信息

编辑不同的视网膜显示

CGRect screenRect = [[UIScreen mainScreen] bounds];
if (screenRect.size.height == 568.0f)
   {
    //condition for iphone 5 screen
   }
else
{
 //condition for retina display 3.5
}
于 2013-07-07T18:35:07.420 回答