Ios 如何根据手机屏幕自动包装长文本页面

Ios 如何根据手机屏幕自动包装长文本页面,ios,uilabel,Ios,Uilabel,我想申请一本书。我对能显示长字符串的文本感到厌烦。基本上,我尝试使用UI标签,但它只显示一行,其余的文本被剪切 你知道我应该用什么样的用户界面来制作一本书吗?谢谢。将UILabel的设置为0,使其使用所需的行数。您必须使用UITextView进行此检查 UITextView *aboutStable = [[UITextView alloc] init]; [aboutStable setFont:[UIFont fontWithName:@"Helvetica" size:12]]; [abo

我想申请一本书。我对能显示长字符串的文本感到厌烦。基本上,我尝试使用UI标签,但它只显示一行,其余的文本被剪切


你知道我应该用什么样的用户界面来制作一本书吗?谢谢。

将UILabel的设置为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];
并将其设置为不可编辑

[关于表setUserInteractionEnabled:否]
应该这样做

如果您需要滚动:

aboutStable.editable = NO;
或者,如果您的文本仍然更多,那么您也可以在其中设置scrollview

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
}

好的,我发现[aboutStable setFrame:CGRectMake(0,032040)];是文本视图的完美矩形。但我还意识到一件事,如果用户使用视网膜显示器或其他大小不同的手机会怎么样。在这种情况下,如何处理多种尺寸的iphone。检查上面答案中的编辑部分。如果有帮助,请不要忘记向上投票!