• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Calling Methods From Custom UIImageView's initWithImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Calling Methods From Custom UIImageView's initWithImage
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions
  • Next by Date: Re: Calling Methods From Custom UIImageView's initWithImage
  • Previous by thread: Re: Is it possible to pass an object to a NIB
  • Next by thread: Re: Calling Methods From Custom UIImageView's initWithImage
  • Index(es):
    • Date
    • Thread