簡體   English   中英

UIImageView不顯示圖像-iPhone SDK

[英]UIImageView not displaying image - iPhone SDK

我正在使用AVFramework捕獲相機幀,我想在UIImageView中進行處理並顯示它們,但遇到了一些麻煩。 我有代碼:

// Delegate routine that is called when a sample buffer was written
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{ 
    //NSLog(@"Capturing\n");
    // Create a UIImage from the sample buffer data
    UIImage *image = [self imageFromSampleBuffer:sampleBuffer];     

    NSLog(@"Image: %f %f\n", image.size.height, image.size.width);
    [imageView setImage:image];
}

但是,它不會顯示。 正確的大小顯示在NSLog ,當我放置時:

[imageView setImage:[UIImage imageNamed:@"SomethingElse.png"]]; 

在viewDidLoad中,圖像正確顯示(所以我知道UIImageView已正確連接)。

有什么理由不可行嗎??? 我現在不知所措。

干杯,布雷特

你是在主線程上做這個嗎? 您可以使用主隊列作為委托(這是不希望的,因為您首先要進行處理),或者:

dispatch_async(dispatch_get_main_queue(), ^{
    imageView.image = ...;
});

imageView是否設置正確? 如果imageView實際上為nil,則調用[imageView setImage:image]; 會無聲無息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM