I have a really simple app, and I'm stuck just in the beginning. Let me post the code right here.
TapStackView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface TapStackView : UIView
{
//Layers.
UIImageView *backgroundImageView;
UIImageView *powerOn;
}
@property (nonatomic, retain) UIImageView *backgroundImageView;
@property (nonatomic, retain) UIImageView *powerOn;
@end
TapStackView.m
#import "TapStackView.h"
@implementation TapStackView
@synthesize backgroundImageView, powerOn;
//Initialize,
-(id)initWithFrame: (CGRect)frame
{
if (self = [super initWithFrame:frame])
{
//Set up layers.
self.backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"layout.png"]];
self.powerOn = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"powerOn.png"]];
self.powerOn.center = CGPointMake(159 + powerOn.frame.size.width/2, 26 + powerOn.frame.size.height/2);
//Attach to the view.
[self addSubview:self.backgroundImageView];
[self addSubview:powerOn];
NSLog(@"initWithFrame - powerOn.center is %f, %f", self.powerOn.center.x, self.powerOn.center.y);
}
return self;
}
//Finger touched.
-(void)touchesBegan: (NSSet*)touches withEvent: (UIEvent*)event
{
NSLog(@"-----");
NSLog(@"touchesBegan - self.powerOn.center is %f, %f", self.powerOn.center.x, self.powerOn.center.y);
}
@end
Console
[Session started at 2010-01-01 21:39:42 +0100.]
2010-01-01 21:39:44.177 TapStack[6261:20b] initWithFrame - powerOn.center is 186.000000, 53.000000
2010-01-01 21:39:45.149 TapStack[6261:20b] -----
2010-01-01 21:39:45.150 TapStack[6261:20b] touchesBegan - self.powerOn.center is 0.000000, 0.000000
2010-01-01 21:39:45.978 TapStack[6261:20b] -----
2010-01-01 21:39:45.979 TapStack[6261:20b] touchesBegan - self.powerOn.center is 0.000000, 0.000000
2010-01-01 21:39:48.914 TapStack[6261:20b] -----
2010-01-01 21:39:48.915 TapStack[6261:20b] touchesBegan - self.powerOn.center is 0.000000, 0.000000
2010-01-01 21:39:50.011 TapStack[6261:20b] -----
2010-01-01 21:39:50.012 TapStack[6261:20b] touchesBegan - self.powerOn.center is 0.000000, 0.000000
I just cannot imagine why can't I see that powerOn property inside the touchesBegan method. Any ideas?