使用AVAssetReader和ARC绘制波形

使用AVAssetReader和ARC绘制波形

本文介绍了使用AVAssetReader和ARC绘制波形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试应用不同步的答案(使用AVAssetReader绘制波形 ),同时使用ARC.只需要进行少量修改,大部分是发布声明.非常感谢您的答复!我正在使用针对iOS5设备的Xcode 4.2.

I'm trying to apply Unsynchronized's answer (Drawing waveform with AVAssetReader) while using ARC. There were only a few modifications required, mostly release statements. Many thanks for a great answer! I'm using Xcode 4.2 targeting iOS5 device.

但是,在尝试调用整个过程时,我最后只能停留在一条语句上.

But I'm getting stuck on one statement at the end while trying to invoke the whole thing.

此处显示的方法:

-(void) importMediaItem {

    MPMediaItem* item = [self mediaItem];

    waveFormImage = [[UIImage alloc ] initWithMPMediaItem:item completionBlock:^(UIImage* delayedImagePreparation){

        [self displayWaveFormImage];
    }];

    if (waveFormImage) {
       [self displayWaveFormImage];
    }
}

在调用initWithMPMediaItem时,出现以下错误:

On the call to initWithMPMediaItem I get the following error:

Automatic Reference Counting Issue.  Receiver type 'UIImage' for instance message
does not declare a method with selector 'initWithMPMediaItem:completionBlock:'

由于我确实在类头中声明了initWithMPMediaItem方法,所以我真的不明白为什么会收到此错误.

Since I do have the method initWithMPMediaItem declared in the class header, I really don't understand why I'm getting this error.

- (id) initWithMPMediaItem:(MPMediaItem*)item
       completionBlock:(void (^)(UIImage* delayedImagePreparation))completionBlock;

曾经尝试将我的头缠了好几个小时,但无济于事.我的方法声明是否适用于这种类型的方法?谢谢!

Been trying to wrap my head around this for several hours now but to no avail. Is my method declaration wrong for this type of method? Thanks!

推荐答案

似乎应该将initWithMPMediaItem声明为UIImage的初始化程序.因此,您应该在头文件的UIImage类别内声明它:

It looks like initWithMPMediaItem should be declared as an initializer for UIImage. So you should declare it inside a UIImage category in your header file:

@interface UIImage (MPMedia)

- (id) initWithMPMediaItem:(MPMediaItem*)item
   completionBlock:(void (^)(UIImage* delayedImagePreparation))completionBlock;

@end

这篇关于使用AVAssetReader和ARC绘制波形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 01:04