我需要帮助解决这个特殊问题。我有一个多项选择题应用程序,我可以选择 UITextview。有时,无论出于何种原因,选项 D 都会被减半。
截图:
不知道这里发生了什么。我基本上让 UITextView 框架调整到它的 contentSize。
CGRect dFrame = choiceD.frame;
dFrame.size.height = choiceD.contentSize.height;
choiceD.frame = dFrame;
有什么想法吗?提前致谢。
最佳答案
计算字符串的大小:
NSString *choiceDString = @"Equal the present value....";
CGSize size = [choiceDString sizeWithFont:[UIFont systemFontOfSize:CHOICE_FONT_SIZE] constrainedToSize:CGSizeMake(CHOICE_WIDTH, 100000)];
初始化一个标签来满足选择字符串:
UILabel *choiceDLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,size.width,size.height)];
choiceDLabel.text= choiceDString;
为按钮添加 subview 标签:
[button addSubview:choiceLabel];
关于iphone - 编辑 : UITextView Label is Cut in Half (Horizontally),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10184495/