i'm trying to understand how to create my own UIImageView class with
it's own custom methods that are fired from the initWithImage method,
but i can't get it to work.  i believe i'm missing something
fundemental, which for some reason hasn't yet clicked in my head, so
please help me understand what i'm doing wrong.

this is my UIImageViewController .h and .m:

–––––
#import <UIKit/UIKit.h>
@class myUIImageViewClass;


@interface myViewController : UIViewController
        {
        myUIImageViewClass *imageViewClass;
        }

@property (nonatomic, retain) myUIImageViewClass *imageViewClass;;

@end
–––––
–––––
#import "myViewController.h"
#import "myUIImageViewClass.h"

@implementation myViewController
@synthesize imageViewClass;


- (void)viewWillAppear:(BOOL)animated
        {
        UIImage *myImage = [UIImage imageNamed:@"myImage.png"];
        imageViewClass = [[UIImageView alloc] initWithImage:myImage];
        [imageViewClass setFrame:CGRectMake(0, 0, myImage.size.width,
myImage.size.height)];
        
        [self.view addSubview:imageViewClass];
        [imageViewClass release];
        
        [super viewWillAppear:animated];
        }

- (void)dealloc
        {
        [imageViewClass release];
        [super dealloc];
        }

@end
–––––


now my custom UIImageView class does get added as a subview, but the
methods that are suppose to fire from the initWithImage class do not
get called.  here are the .h and .m for myUIImageViewClass


–––––
#import <Foundation/Foundation.h>

@interface myUIImageViewClass : UIImageView
        {
        }

- (void)logImageSize:(UIImage *)image;

@end
–––––
–––––
#import "myUIImageViewClass.h"

@implementation myUIImageViewClass

- (id)initWithImage:(UIImage *)image
        {
        if (self = [super initWithImage:image])
                [self logImageSize:image];
                
        return self;
        }

- (void)logImageSize:(UIImage *)image
        {
        NSLog(@"Width:%.0f – Height:%.0f", image.size.width, image.size.height);
        }

@end
–––––
_______________________________________________

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