0
我已完成调整UITextView
的大小以适应其内容使用以下代码片段(source)。可调整大小的UITextView以适应其内容
UITextView* textView = [[UITextView alloc]initWithFrame:CGRectMake(0.0f,0.0f,300.0f,10.0f)];
[self.view addSubview:textView];
textView.text = @"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s";
CGRect frame = textView.frame;
frame.size.height = textView.contentSize.height;
textView.frame = frame;
我的问题是,我不想以编程方式创建UITextView
。当我从Interface Builder添加它并通过@property
引用它时,上面的代码不起作用。 frame
返回null
。我已经把里面viewDidLoad
这个代码,所以我认为这是因为在UITextView
的初始化或添加到视图控制器,但(?)
有另一种方式来做到这一点,而无需创建UITextView
编程?
嗨感谢您的回复。是的,我确实评论了这些线,并仔细检查了连接。虽然没有用 – Isuru