2011-07-06 6 views
1

lblOverlayView_text.text @ "英語サブタイトル"から@ "変更"に変更しません。私の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]; 
} 

答えて

7

ラベルをバックグラウンドスレッドから更新しています。 UI要素は常にメインスレッドから更新する必要があります。

[lblOverlayView performSelectorOnMainThread:@selector(setText:) withObject:@"Change" waitUntilDone:NO]; 
+0

最後に私のuilabelのテキストが変更されましたが、UI要素は常にメインスレッドから更新する必要があります.---奇妙な理由、ありがとうmortenfast – libai

関連する問題