メインスレッドで行う必要のあるUIのすべての変更、使用してみてくださいperformSelectorOnMainThread:withObject:waitUntilDone:
電話
//...
for(int i=0;i<[testochar count];i++){
NSString *y=[testochar objectAtIndex:i];
[NSThread sleepForTimeInterval:0.1f];
NSDictionary *arg = [NSDictionary dictionaryWithObjectAndKeys:
self.txtview, @"textView",
y, @"string", nil ];
[self performSelectorOnMainThread:@selector(updateTextForTextView:) withObject:arg waitUntilDone:NO];
}
//.....
-(void)updateTextForTextView:(NSDictionary*)arg {
NSString *string = [arg objectForKey:@"string"];
UITextView *textView = [arg objectForKey:@"textView"];
self.txtview.text=[self.txtview.text stringByAppendingString:string];
}
(アップデート)
試す
- (void)viewDidLoad {
[super viewDidLoad];
textView.text = @"";
[[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(update) userInfo:nil repeats:YES] retain];
}
-(void) update {
static char text[] = "HELLO";
static int i =0;
if (text[i%6]==0) {
textView.text = [NSString stringWithFormat:@""];
} else {
textView.text = [NSString stringWithFormat:@"%@%c", textView.text, text[i%6] ];
}
i++;
}
次のように機能します:
http ://www.youtube.com/watch?v = tB2YKX4zpY4