Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set UIImage of UITableViewCell #13

Open
steilerDev opened this issue Apr 19, 2015 · 7 comments
Open

Unable to set UIImage of UITableViewCell #13

steilerDev opened this issue Apr 19, 2015 · 7 comments

Comments

@steilerDev
Copy link

I am trying to use your library to set the image of a UITableViewCell (basic style).

I am using the following method to do so: cell.imageView?.setImageWithString(user.displayName, color: UIColor(hex: MVColor.Primary.Normal))

Unfortunately the image is not set and I am getting the following error:

<Error>: CGContextRestoreGState: 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.

I tried debugging the error. By using this method I found the cause of this problem. The error is produced by this call: CGContextTranslateCTM(context, -self.bounds.origin.x, -self.bounds.origin.y); (line 121 in your latest CocoaPods release) in your - (UIImage *)imageSnapshotFromView:(UIView *)inputView function.

It would be great to resolve this problem or find a workaround!

Thanks

@bachonk
Copy link
Owner

bachonk commented Apr 19, 2015

Hey @steilerDev, thanks for pointing this out. Try pulling down the latest cocoapod release, and let me know if that fixes things.

@steilerDev
Copy link
Author

Hey @bachonk, thanks for getting back that fast. I can see that you released a new version on Github, but CocoaPods is not updating (when running pod update). Is it a problem on your side or on CocoaPods side (Never looked how they actually detect new versions)?

Edit: Cocoapods.org is still listing your pod as version 1.0

@bachonk
Copy link
Owner

bachonk commented Apr 19, 2015

Forgot to push up the latest to cocoapods, thanks for pointing that out. Try now

@steilerDev
Copy link
Author

Pod update worked, unfortunately the error persists :/

@steilerDev
Copy link
Author

I am not sure, but by looking at the error and your code, I think the problem is that the size of the image view is not set until you are setting an actual image into the view. Your framework uses the size of the context to create the image, which is not possible (or lead to that error) because the context size is 0x0 before setting the image.

Not sure if this is a fix but having a function that would explicitly draw inside a rect and return/set the image. Something like imageFromText:inRect: might help. Does that make sense?

@mariovillamizar
Copy link

You must set frame for cell uimageview.

[cell.uiimageview setframe:cgrectmake(0,0,width, height)];

@YahyaBagia
Copy link

See here
Issue 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants