FROM : Vince Ackerman
DATE : Fri Nov 30 19:04:51 2007
Excuse my sloppy code... but this was my kludge to test if I could
resize the grid of subviews.
-(void)resizeDayViews: (NSSize) size // Adjust all subViews for size
of Main view
{
NSArray *subDayViews = [self subviews]; // get array of all subviews
NSEnumerator *enumerator = [subDayViews objectEnumerator]; // get
enumerator to step through the subview array
NSRect newBounds = [self bounds]; // get current bounds rect
NSRect newRect;
NSLog( @"Start of Resize Method------------------------------");
float dayWidth = ( (newBounds.size.width - 9) / 7);
float weekHeight = ( (newBounds.size.height - 9) / 6) ;
int x,y,rowCnt, columnCnt;
// for each row of days
for (y = 5, rowCnt = 0; rowCnt < 6; y = y + weekHeight, rowCnt++)
{
for(x = 5, columnCnt = 0; columnCnt < 7; x = x + dayWidth, columnCnt+
+)
{
newRect = NSMakeRect(x, y, dayWidth, weekHeight );
DayView *tempView = [enumerator nextObject];
[ tempView setFrame: newRect ];
NSLog( @"frame set");
NSLog( @"%@", [NSString stringWithFormat:@"%i", [tempView
gridNum] ]);
NSLog(@"%@", NSStringFromRect(newRect) );
NSLog(@"%@", NSStringFromRect([ tempView frame]) );
}
}
}
On Nov 30, 2007, at 09:55, Joshua Emmons wrote:
>> For some reason each time the resizeSubview method is called,
>> NSEnumerator alternately returns with either the first subview in
>> the array, or the last. The first time the method is called, the
>> first subview is number 0, continuing through 41. The next time it
>> goes through the array, the enumerator starts with subview 41,
>> skips subview 0, and iterates to subview 1, then 2, 3 etc.
>
> I haven't come across this behavior before, and a quick sample app
> doesn't exhibit it. Maybe give some more details about your
> implementation? Maybe it's a bug with how your calling NSEnumerator?
>
> Cheers,
> -Joshua Emmons
DATE : Fri Nov 30 19:04:51 2007
Excuse my sloppy code... but this was my kludge to test if I could
resize the grid of subviews.
-(void)resizeDayViews: (NSSize) size // Adjust all subViews for size
of Main view
{
NSArray *subDayViews = [self subviews]; // get array of all subviews
NSEnumerator *enumerator = [subDayViews objectEnumerator]; // get
enumerator to step through the subview array
NSRect newBounds = [self bounds]; // get current bounds rect
NSRect newRect;
NSLog( @"Start of Resize Method------------------------------");
float dayWidth = ( (newBounds.size.width - 9) / 7);
float weekHeight = ( (newBounds.size.height - 9) / 6) ;
int x,y,rowCnt, columnCnt;
// for each row of days
for (y = 5, rowCnt = 0; rowCnt < 6; y = y + weekHeight, rowCnt++)
{
for(x = 5, columnCnt = 0; columnCnt < 7; x = x + dayWidth, columnCnt+
+)
{
newRect = NSMakeRect(x, y, dayWidth, weekHeight );
DayView *tempView = [enumerator nextObject];
[ tempView setFrame: newRect ];
NSLog( @"frame set");
NSLog( @"%@", [NSString stringWithFormat:@"%i", [tempView
gridNum] ]);
NSLog(@"%@", NSStringFromRect(newRect) );
NSLog(@"%@", NSStringFromRect([ tempView frame]) );
}
}
}
On Nov 30, 2007, at 09:55, Joshua Emmons wrote:
>> For some reason each time the resizeSubview method is called,
>> NSEnumerator alternately returns with either the first subview in
>> the array, or the last. The first time the method is called, the
>> first subview is number 0, continuing through 41. The next time it
>> goes through the array, the enumerator starts with subview 41,
>> skips subview 0, and iterates to subview 1, then 2, 3 etc.
>
> I haven't come across this behavior before, and a quick sample app
> doesn't exhibit it. Maybe give some more details about your
> implementation? Maybe it's a bug with how your calling NSEnumerator?
>
> Cheers,
> -Joshua Emmons






Cocoa mail archive

