1
lblOverlayView_text.text不會從@「english subtitle」更改爲@「change」;我的uilabel文字無法更改,爲什麼?
如何改變,爲什麼不呢?
- (void)video123 {
lblOverlayView = [[UILabel alloc] init];
int height=40;
lblOverlayView.frame = CGRectMake(0, 480-height, 320, height);
lblOverlayView.backgroundColor = [UIColor grayColor];
lblOverlayView.alpha = 0.5f;
lblOverlayView.text = @"english subtitle";
lblOverlayView.textColor=[UIColor greenColor];
lblOverlayView.textAlignment=UITextAlignmentCenter;
NSString *[email protected]"http://video.ted.com/talk/stream/2011U/Blank/MattCutts_2011U-320k.mp4";
movieURL= [NSURL URLWithString:urlAddress];
//MPMoviePlayerViewController *
moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[moviePlayer.view addSubview:lblOverlayView];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
[NSThread detachNewThreadSelector:@selector(thread) toTarget:self withObject:nil];
NSLog(@"loop test end playback starting...");
}
- (void) thread{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
while (true)
{
[NSThread sleepForTimeInterval: 0.2];
lblOverlayView.text = @"change";
}
[pool drain];
}
謝謝,最後我的uilabel文本被改變了,UI元素必須總是從主線程更新.-----奇怪的原因,謝謝mortenfast – libai