> On Jul 30, 2014, at 10:18 AM, Dave <[email protected]> wrote:
> 
> XCode 5, Mac OS 10.9.4, iOS 7.
> 
> Hi,
> 
> I'm working on a project that uses a lot of view “cells” that go into Scroll 
> and Table Views. Each “cell” View is in separate .xib file and is loaded 
> something like this:
> 
> +(instancetype) newViewOfKind:(NSString*) theViewKind 
> withItemInfo:(LTWItemInfo*) theItemInfo
> {
> NSString*     myClassName;
> LTWItemView*  myNewCell;
> 
> myClassName = NSStringFromClass([self class]);
> myNewCell = [[super class] newViewOfKind:theViewKind withItemInfo:theItemInfo 
> andNIBBaseName:myClassName];
> 
> if (myNewCell.pItemActivityIndicator != nil)
>       myNewCell.pItemActivityIndicator.hidesWhenStopped = YES;
> 
> myNewCell.pItemDownloadImageLoadedFlag = NO;
> myNewCell.pItemDownloadImage = nil;
> [myNewCell setItemInfo:theItemInfo];
> 
> return myNewCell;
> }
> 
> 
> This works well and is being used in lots of places in the App. 
> 
> This project was originated before Auto-Layout was around and it is off in 
> all the cell .xib files. 
> 
> The .xib file for each of these views has a “standard” layout that looks like 
> this:
> 
> LTWItemView.xib   — Auto-Layout off.
> 
> LTWItemView 
>       “FrameRect” - View of Class “LTWDrawFrameView” Inside LTWItemView above 
>  (this is a normal view, but drawRect overridden to draw a frame around the 
> view).
>              Inside the “FrameRect” view, other views UILabels, 
> UIImageView’s, UIButton’s, etc.
> 
> The problem is that the drawRect method in “FrameRect” does not get called 
> and it’s background colour doesn’t get set either. When I first created this 
> view, I had Auto-Layout enabled and in this case the background colour is set 
> ok and the drawRect is called. 

-drawRect: is driven by -setNeedDisplay, which is driven by things such as 
frame changes. The likely difference in your scenarios is simply that the frame 
isn’t changing. But views when created are also set to need to be drawn, so I 
would expect it to be called at least once when coming from the nib.

But your mentioning of background color is kind of strange, since that should 
be set regardless of -drawRect: being called – or are you doing things 
unrelated to drawing inside of -drawRect:?

> 
> The problem is that if I enabled Auto-Layout, it causes problems elsewhere 
> and it’s too big a job to convert the project to use it.
> 
> Any ideas on how to solve this would be greatly appreciated.
> 
> Thanks a lot
> Dave
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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/david.duncan%40apple.com
> 
> This email sent to [email protected]

--
David Duncan


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to