UITextView分页不滚动

时间:2015-04-03 23:33:39

标签: swift uiscrollview uitextview paging

以前问过的问题完全相同,但是我希望有人将答案的代码转换为Swift,因为它在objective-c中。我也想在故事板中做大部分这个,SO用户可以帮帮我吗? UITextView in UIScrollView with paging not scrolling

如果你懒得查看链接,就像我们都是:

CGRect labelFrame;
UITextView *textView;

labelFrame.size.width = scrollView.frame.size.width-24;
labelFrame.size.height = scrollView.frame.size.height-48;
labelFrame.origin.x = 10;
labelFrame.origin.y = 40;

textView = [[UITextView alloc] initWithFrame:labelFrame];
textView.textColor = [UIColor blackColor];
textView.backgroundColor = [UIColor redColor];
textView.font = [UIFont systemFontOfSize:13];
textView.text = @"a very long text";

textView.editable = NO;
textView.scrollEnabled = YES;
textView.userInteractionEnabled = YES;
textView.delegate = self;
textView.contentSize = CGSizeMake(1, 1000); //this would make it scroll?
[subview addSubview:textView];

另外,问题的答案我并不完全理解他所说的话。

2 个答案:

答案 0 :(得分:0)

我不确定我是否完全理解您的问题,但是如果您想在故事板中启用UITexView中的滚动,请从对象库中拖放UITextView并选择"滚动启用"属性检查器中UITextField的属性。 Select 'Scrolling Enabled'

答案 1 :(得分:0)

删除 textView.scrollEnabled = YES; textView.userInteractionEnabled = YES; 并粘贴

textView.isSelectable = false
textView.isEditable = false