在ios 7上动态扩展UITextView [英] Dynamic expand UITextView on ios 7

查看:74
本文介绍了在ios 7上动态扩展UITextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此代码

CGRect frame = self.mytext.frame;
frame.size.height = self.mytext.contentSize.height;
self.mytext.frame = frame;

但它在iOS 7中不起作用。有谁知道为什么或有同样的问题?

But it doesn`t work in iOS 7. Does anyone know why or have the same problem?

已编辑:

抱歉。
我制作了一个UIView,一个UITextView和一个UIScrollView,所以我可以在我的uitextview expand中加载文本。

Sorry. I made an UIView, a UITextView and a UIScrollView so i can load the text in my uitextview expand.

我在viewDidLoad中使用了这段代码

I used this code in viewDidLoad

CGRect frame = self.moreDetailsTextView.frame;
frame.size.height = self.moreDetailsTextView.contentSize.height;
self.moreDetailsTextView.frame = frame;

CGRect moreViewFrame =  self.moreDetailsView.frame;
moreViewFrame.size.height = frame.size.height + 270;
self.moreDetailsView.frame = moreViewFrame;

int scrollViewHeight =  moreViewFrame.size.height + 235;
self.scrollView.contentSize = CGSizeMake(320, scrollViewHeight);

这在ios6中工作正常,但是现在使用xcode5和ios7时uitextview在我测试时不会扩展模拟器中的应用程序。

This was working fine in ios6, but now with xcode5 and ios7 the uitextview does not expand when i test the app in the simulator.

推荐答案

在IOS7中注意到sizeToFit也不起作用 - 也许解决方案也可以帮助你

Noticed in IOS7 sizeToFit wasn't working also - perhaps the solution may help you too

[UITEXTVIEW sizeToFit];
[UITEXTVIEW layoutIfNeeded];

这篇关于在ios 7上动态扩展UITextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆