旋转到 UIInterfaceOrientationLandscapeRight 时如何使 UITextView 中的文本变宽

发布于 2024-08-08 13:16:51 字数 503 浏览 0 评论 0原文

我将一些文本放入 UITextView 中。现在我想让内部文本在设备成为地平线时占据额外的空间。但这种方式只能让画布填充所有空间而不是文本。

// This method is called by NSNotificationCenter when the device is rotated.
-(void) receivedRotate: (NSNotification*) notification
{
 UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

 if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
 {
  self.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
  self.view.bounds = CGRectMake(0, 0, 416, 320);

I put some text into a UITextView. Now I wanna make the inside text occupy the additional space when device become horizon. But this way only make canvas fill in all the space not the text.

// This method is called by NSNotificationCenter when the device is rotated.
-(void) receivedRotate: (NSNotification*) notification
{
 UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

 if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
 {
  self.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
  self.view.bounds = CGRectMake(0, 0, 416, 320);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独留℉清风醉 2024-08-15 13:16:51

您是否在视图中使用 xibs 和界面生成器?如果是这样,您应该能够使用 支柱和弹簧 使 UITextView 自动调整大小。

如果没有,您必须在 receivedRotate: 方法中以编程方式重置 UITextView 的大小。

Are you using xibs and interface builder for your views? If so, you should be able to use struts and springs to have the UITextView resize automatically.

If not, you'll have to reset the UITextView's size programmatically in the receivedRotate: method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文