jameswomack / iOS-Image-Filters

High-level CIImage-based image filtering on iOS 6+ using CoreImage & raster graphic overlays
http://womack.io
MIT License
132 stars 27 forks source link

UIImage+Filter.m category conflicts with standard UIControls #5

Closed dgoldman-pdx closed 9 years ago

dgoldman-pdx commented 9 years ago

This category method:

@implementation NGImage (Filter)
- (CIImage *)CIImage {
  return [CIImage imageWithCGImage:self.CGImage];
}

Has problems with views containing either UISegmentedControl or UISwitch.

For UISegmentedControl, under iOS 8 there is a crash (EXC_BAD_ACCESS inside [UIImage imageWithRenderingMode:]). Under iOS 7 there is no crash, but the UISegmentedControl is badly rendered onscreen.

For UISwitch, under iOS 8 the switch is rendered badly onscreen.

I've created a small sample project that illustrates these issues. (It currently contains a UISegmentedControl in its main storyboard. You can replace that with a UISwitch to confirm the iOS 8 issue there.)

I'm wondering whether the - (CIImage *)CIImage method is still necessary under iOS 7 and/or 8. Perhaps it can be conditionally compiled, or eliminated altogether?

jameswomack commented 9 years ago

@dgoldman-ebay I apologize—my company email address changed and it resulted in some dropped Github notifications.

Does this issue remain?

dgoldman-pdx commented 9 years ago

Thanks for catching this, @jameswomack.

I don't know of anything relevant that might have changed in the past couple of weeks, so I presume that the problem remains, as described above.

jameswomack commented 9 years ago

@dgoldman-ebay I can see that Apple has now implemented some of the methods from this project. That's what's causing this issue and I'll get it fixed.

jameswomack commented 9 years ago

Using a category method seems to fix it. I've committed this change.

dgoldman-pdx commented 9 years ago

Thanks, @jameswomack, I appreciate your effort. I'll give your new code a try tomorrow.

At first glance it looks like you're using a compile-time test to determine whether to proceed as for iOS 8 or for pre-iOS 8. But since the same binary might be run on any version of iOS, don't you need a runtime test instead? (Also, see the original description above re iOS 7 rendering issues.)

jameswomack commented 9 years ago

@dgoldman-ebay Code updated, and now also published to CocoaPods. There's no longer a build-time check. I haven't seen any rendering issues on 7 or 8 since I namespace CIImage and imageClampingToExtent. Example app screener

dgoldman-pdx commented 9 years ago

Looks good, @jameswomack! Thanks.