开发者

my uilabel text can not change , why?

开发者 https://www.devze.com 2023-03-17 20:10 出处:网络
lblOverlayView_text.textdo not change from@\"english subtitle\"to@\"change\"; how to change, and why not ?

lblOverlayView_text.text do not change from @"english subtitle" to @"change";

how to change, and why not ?

- (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 *urlAddress=@"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 withO开发者_如何转开发bject: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];
}


You are updating your label from a background thread. UI elements must always be updated from the main thread.

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

精彩评论

暂无评论...
验证码 换一张
取 消