相关疑难解决方法(0)

在iOS 7中滚动到UITextView的底部不稳定

以下代码在iOS <7.0中可以正常工作.在iOS 7中,当UITextView正在更新时,滚动将变得不稳定且不稳定.我不确定这是否是iOS 7中的错误,或者我做错了什么.

TestController.h

//TODO: Add UITextView in storyboard and tie to textView outlet

#define MAX_TEXT_VIEW_CHARACTERS 1000
@interface TestController : UIViewController  {
    NSMutableString *_outputText;
    NSTimer *_outputTimer;
}

@property (strong, nonatomic) IBOutlet UITextView *textView;

@end
Run Code Online (Sandbox Code Playgroud)

TestController.m

@implementation TestController
@synthesize textView;

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    _outputText = [NSMutableString stringWithCapacity:MAX_TEXT_VIEW_CHARACTERS];
    _outputTimer =  [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(outputLine:) userInfo:nil repeats:YES];
}

-(void)outputLine:(NSTimer *) theTimer {
    static int i = 0;
    //Run this 100 times
    if (i > 99) {
        [_outputTimer invalidate];
        return;
    } …
Run Code Online (Sandbox Code Playgroud)

uiscrollview uitextview ios ios7

25
推荐指数
2
解决办法
2万
查看次数

以编程方式滚动到textView的底部

我创建了一个按钮,为textView添加了一些文本,我希望它在按下时自动滚动到底部,以便用户能够看到添加的新文本.
我无法在Swift中使用解决方案,因为我不了解Objective-C.有谁知道如何在Swift中滚动到textView的底部?谢谢.

ios swift

23
推荐指数
4
解决办法
1万
查看次数

标签 统计

ios ×2

ios7 ×1

swift ×1

uiscrollview ×1

uitextview ×1