On Jun 19, 2009, at 2:20 PM, Chunk 1978 wrote:

so i'm forced to subclass the rect...

Hmm... There's no such thing as "subclassing a rect". CGRect is a structure, not a class.


my StrokeView:UIView class.m is this:

- (id)initWithFrame:(CGRect)frame {
   if (self = [super initWithFrame:frame]) {
      frame = CGRectMake(10, 10, 100, 100);
   }
   return self;
}

You've changed the value of the local variable "frame". If you want to resize your view you will have to either change the frame before calling super, or use self.frame = CGRectMake(10, 10, 100, 100) after self has been initialized.

- (void)drawRect:(CGRect)rect
        {
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
        CGContextStrokePath(context);
        }

You asked for the current path to be stroked, but you haven't told the context what the current path is. Somewhere in there before the StrokePath you probably want to do:

CGContextAddRect(context, CGRectMake( <... whatever rect you like here...>));


now in my may app controller.h i have the following:

@class StrokeView;
@interface AppController : UIViewController
        {
        StrokeView *strokeViewClass;
        }

@property (nonatomic, retain) StrokeView *strokeViewClass;

and in the implementation file, i'm calling for the class to be added
as a subview with this:

#import "StrokeView.h"
[self.view insertSubview:strokeViewClass atIndex:1];

totally doesn't work.

Do you ever allocate the strokeView? You've declared that your UIViewController knows about a stroke view, but you've not actually created one (at least not with this code example).

It would seem that there is a lot here you don't understand. I would recommend going back and looking at some basic examples and perhaps some of the sample code to see if you can learn a bit more.

Scott

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to