Note that there are some explanatory texts on larger screens.

plurals
  1. PO-setNeedsDisplay not getting called to refresh drawRect
    text
    copied!<p>I have two methods that get called from within <code>-drawRect:</code></p> <pre><code>- (void)drawRect:(CGRect)rect { if(drawScheduleFlag) { [self drawSchedule]; drawScheduleFlag = false; } else [self drawGrid]; } </code></pre> <p><code>-drawGrid</code> is called at initialization time. The other method (<code>-drawSchedule</code>) is called from this code, which is on the main thread:</p> <pre><code>- (void) calendarTouched: (CFGregorianDate) selectedDate { // NSLog(@"calendarTouched - currentSelectDate: %d/%d/%d", selectedDate.month, selectedDate.day, selectedDate.year); // NSLog(@"Main thread? %d", [NSThread isMainThread]); // get data from d/b for this date (date, staff name, cust name, time, length, services required) //------ stub ------- scheduledDate.year = 2012; scheduledDate.month = 6; scheduledDate.day = 20; staffName = @"Saori"; custName = @"Brian"; startTime.hour = 11; duration = 2; servicesReqd = @"Nails"; drawScheduleFlag = true; [self setNeedsDisplay]; return; } </code></pre> <p>I know the code is being executed, but nothing happens to draw the schedule. Why is <code>-[self setNeedsDisplay]</code> not causing the <code>-drawRect</code> to be called?</p> <p>UPDATE: I have put breaks in so I'm positive it's not being called. The original grid is drawn once; when the user taps a calendar date, -calendarTouched is called and completely executed. The drawScheduleFlag is set to true, and -[self setNeedsDisplay] gets called, but -drawRect does not. It appears that the UIView is not being invalidated (which -setNeedsDisplay is supposed to do), therefore -drawRect is not called.</p> <p>UPDATE #2: I have a .xib for a UIViewController with two (2) UIViews in it. The first UIView takes about 1/3 of an iPad screen, the second UIView takes the bottom 2/3 of the screen. Each UIView has it's own specific class; the top UIView displays a calendar and is working correctly, capturing touches and changing the date selected.</p> <p>The bottom UIView is supposed to show the schedule for the date picked in the top UIView. This is where the problem is. Since the top UIView is working, I will put up the code for the bottom UIView's class. It basically draws the schedule grid when -drawRect is first called. Once the user has selected a day, it is supposed to invalidate the UIView to draw the actual schedule on the grid.</p> <p>Here is the code for Schedule.h: <a href="http://pastebin.com/NQpj0i07" rel="nofollow">http://pastebin.com/NQpj0i07</a> Here is the code for Schedule.m: <a href="http://pastebin.com/YBbE8y0T" rel="nofollow">http://pastebin.com/YBbE8y0T</a> Here is the code for the controller: <a href="http://pastebin.com/nDqBCivj" rel="nofollow">http://pastebin.com/nDqBCivj</a> Note that both pastebin's expire in 24 hours from Jun 28, 5:38 PM PST</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload