Voir le code icipassage Valeur de l'objet à UIView
@interface StaticView : UIView {
Properties *prop;
}
@property (retain) Properties *prop;
@end
et je joins ce point de vue via le code
[super viewDidLoad];
StaticView *sView = [[StaticView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
sView.prop.glowIntensity = 0.85f;
[self.view addSubview:sView];
mais dans mon drawRect Méthode de StaticView je suis toujours reçois prop.glowIntensity = 0,0000
- (void)drawRect:(CGRect)rect {
NSLog(@"%f", prop.glowIntensity);
}
Voici mon Properties.h
@interface Properties : NSObject {
UIColor *bgColor;
UIColor *foreColor;
float glowIntensity;
}
@property(retain) UIColor *bgColor;
@property(retain) UIColor *foreColor;
@property float glowIntensity;
-(void) initbgColor:(UIColor *)bgC foreColor:(UIColor *)fC glowIntensity:(float) gI;
@end
ici est la mise en œuvre Properties.m
#import "Properties.h"
@implementation Properties
@synthesize bgColor;
@synthesize foreColor;
@synthesize glowIntensity;
-(void) initbgColor:(UIColor *)bgC foreColor:(UIColor *)fC glowIntensity:(float) gI
{
self.bgColor = bgC;
self.foreColor = fC;
self.glowIntensity = gI;
}
@end
Comment puis-je passer juste valeur à ma classe StaticView?
Nous devons également examiner votre implémentation de 'Properties'. Peut-être que l'ivar 'glowIntensity' n'est pas déclaré correctement? – bddckr
Code pour Properties.h et Properties.m ajouté – coure2011