rFlex / SCWaveformView

A blazing fast customizable waveform view
Apache License 2.0
457 stars 59 forks source link

errors and can't see a waveform #3

Closed jabelman closed 10 years ago

jabelman commented 10 years ago

Here is my code:

UIButton tempButton = (UIButton ) sender; SCWaveformView waveformView = [[SCWaveformView alloc] init]; AVAsset asset = [AVURLAsset URLAssetWithURL:currentRecordingPath options:nil]; waveformView.asset = asset; waveformView.normalColor = [UIColor greenColor]; [waveformView generateWaveforms]; UIImage normalWaveformImage = waveformView.generatedNormalImage; UIImageView waveformimageview = [[UIImageView alloc] initWithFrame:tempButton.frame]; waveformimageview.image = normalWaveformImage; waveformimageview.backgroundColor = [UIColor purpleColor]; [scrollView addSubview:waveformimageview];

I can see the purple background color but I never actually get a waveform.

This gets printed to the console when my app runs through your code:

: CGContextSetAllowsAntialiasing: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextSetLineWidth: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
rFlex commented 10 years ago

Hey Josh,

Is the asset already recorded or currently in the process of being recorded? This waveform object only handle assets that are local and already fully created.

On Saturday, March 8, 2014, Josh Abelman notifications@github.com wrote:

Here is my code:

UIButton tempButton = (UIButton ) sender; SCWaveformView waveformView = [[SCWaveformView alloc] init]; AVAsset asset = [AVURLAsset URLAssetWithURL:currentRecordingPath options:nil]; waveformView.asset = asset; waveformView.normalColor = [UIColor greenColor]; [waveformView generateWaveforms]; UIImage normalWaveformImage = waveformView.generatedNormalImage; UIImageView waveformimageview = [[UIImageView alloc] initWithFrame:tempButton.frame]; waveformimageview.image = normalWaveformImage; waveformimageview.backgroundColor = [UIColor purpleColor];

[scrollView addSubview:waveformimageview];

I can see the purple background color but I never actually get a waveform.

This gets printed to the console when my app runs through your code:

: CGContextSetAllowsAntialiasing: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextSetLineWidth: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. : CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

Reply to this email directly or view it on GitHubhttps://github.com/rFlex/SCWaveformView/issues/3 .

jabelman commented 10 years ago

its been recorded already

jabelman commented 10 years ago

I fixed it after reading this because my breakpoint inside of drawRect wasnt ever hitting: http://stackoverflow.com/questions/12468320/setneedsdisplay-not-calling-drawrectcgrectrect

I turned init into initWithFrame and now drawRect gets called

rFlex commented 10 years ago

Yeah I understand what happened. I was first going to warn you about the way you used the waveform. The waveformview already has a imageview for displaying the waveform. You can use it like a way to display a waveform. Anyway it didn't worked because the frame size of the SCWaveformView was 0,0, so it can't create a CGContext with a size like that.

Glad you found it yourself :)