Calling Methods From Custom UIImageView's initWithImage
Calling Methods From Custom UIImageView's initWithImage
- Subject: Calling Methods From Custom UIImageView's initWithImage
- From: Chunk 1978 <email@hidden>
- Date: Sat, 5 Dec 2009 01:47:00 -0500
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 (email@hidden)
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:
This email sent to email@hidden