UITextView旋转导致内容大小比帧宽更宽 [英] UITextView rotation causes content size to be wider than frame width
问题描述
基本上我有一个UITextView,当我旋转它时,内容大小比帧大小宽。当框架外没有文本时,这会导致文本视图水平滚动。不需要这种行为。
Basically I have a UITextView and when I rotate it the content size is wider than the frame size. This causes the text view to scroll horizontally, when there is no text outside of the frame. This behavior is not wanted.
UITextView *ingredientsTextView = [[[UITextView alloc] initWithFrame:CGRectMake(50, 100,315,300)] autorelease];
[ingredientsTextView setBackgroundColor:[UIColor clearColor]];
[ingredientsTextView setEditable:NO];
[ingredientsTextView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
[ingredientsTextView setFont:[UIFont fontWithName:@"Helvetica" size:18]];
[ingredientsTextView setText:ingredientsText];
ingredientsTextView.transform = CGAffineTransformMakeRotation((3.44*M_PI)/180);
[ingredientsView addSubview:ingredientsTextView];
我无法理解为什么会这样。即使放入 setContentSize
方法也会导致它水平滚动(仅约5 / 10pts),即使宽度为< 100!
I can't understand why this is happening. Even putting in a setContentSize
method causes it to scroll horizontally (only by about 5/10pts) even when the width is < 100!
任何想法?这只是旋转的副作用吗?
Any ideas? Is it just a side effect of rotation?
谢谢
Tom
Thanks Tom
推荐答案
我认为你应该不要旋转textView,你应该旋转的是它下面的视图。例如,navigationController的视图,或viewController的内容视图。
I think you should not rotate the textView, what you should rotate is the view under it. For example, the view of navigationController, or the content view of a viewController.
这篇关于UITextView旋转导致内容大小比帧宽更宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!