> On 13 May 2015, at 9:15 am, Akis Kesoglou <akiskesog...@gmail.com> wrote:
> 
> 
>> On 13 Μαΐ 2015, at 02:04, Graham Cox <graham....@bigpond.com> wrote:
>> 
>> One possible issue in this case is that the first time -drawRect: for any 
>> instance is called, it calls a class method to load the image from a 
>> resource, which is then retained indefinitely. 
> 
> There's a method if I remember correctly that you can use to prepare an 
> IB_DESIGNABLE view: - (void)prepareForInterfaceBuilder
> 


Ah, that’s pretty helpful.

I used this method to establish all the property value defaults that are used 
when drawing. Now, IB displays my controls and is no longer complaining.

What’s weird is that I set all the same property defaults in -initWithFrame: 
(n.b. this nib file is set NOT to prefer NSCoder).

It’s pretty reasonable to expect the drawing a view does to take into account 
any number of properties, and that those properties may be IBInspectable. 
However without forcing the values to their defaults again in 
-prepareForInterfaceBuilder, many of them end up at 0. In this case that led to 
a number of drawing parameters becoming NaNs, which was why Core Graphics was 
throwing an exception. It’s also possible that it was causing some drawing to 
take an “infinite” amount of time to draw though I can’t quite see where that 
could have arisen. I’ve added a few additional sanity checks to catch 
unexpected zeros.

So it looks as if a property that is IBInspectable may be getting incorrectly 
set to 0 by IB AFTER -initWithFrame: is called, maybe because the user 
interacts with the inspectable properties but doesn’t set a value - rather than 
leaving it alone it forces it to 0. That’s definitely a bug. It could also be 
caused by the stale values I mentioned before, where removing IBInspectable 
attribute from a property doesn’t remove the property setting in the nib.

Overall, looks promising but right now too buggy to rely on. :(

—Graham





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to