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

查看:22
本文介绍了在 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 展开中加载文本.

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天全站免登陆