結束時,我有下面的類爲什麼 - (空)在我的對象
#import <UIKit/UIKit.h>
@interface UIImageViewInfo : UIImageView
@property(nonatomic,strong) NSString* colorInfo;
@end
在功能1(後下)創建UIImageViewInfo當我得到正確的結果
「UIImageViewInfo :0x1d8acd60;基類=的UIImageView;幀=(0 0; 20 20);不透明= NO; userInteractionEnabled = NO;標記= 2000;層= 的CALayer:0x1d8a0560 >>」
但創造的函數2東西(貼在下面),我得到的 - (空)
UIImageViewInfo:0x8372c40; baseClass = UIImageView; frame =(0 0; 20 20); alpha = 0;隱藏= YES; opaque = NO; userInteractionEnabled = 否; tag = 2000; layer = CALayer:0x8380090 >> - (null)
爲什麼會有 - (null)?
Thanx提前
PS>這裏是我的代碼
-(void)function1{
UIImageViewInfo *image;
self.solutionPinSlots = [[NSMutableArray alloc] init];
for (int i=0; i<M; i++) {
image = [[UIImageViewInfo alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]];
image.translatesAutoresizingMaskIntoConstraints=NO;
image.hidden=YES;
image.alpha = 0;
image.colorInfo = @"clear";
image.tag = 2000*(self.brainController.slotsIndex+1) +i;
[self.solutionPinSlots addObject:image];
[self.view addSubview:(UIImageViewInfo *)self.solutionPinSlots[i]];
}
NSLog(@"solutionSlots: %@",self.solutionPinSlots);
__block int counter = 0;
[self.brainController.solution enumerateObjectsUsingBlock:^(NSString *peg, NSUInteger idx, BOOL *stop){
for (int i=0;i<M;i++) {
if ([self.brainController.slots[self.brainController.slotsIndex][i] isEqual:peg]) {
if (i==idx) {
((UIImageViewInfo *) self.solutionPinSlots[counter]).backgroundColor = [UIColor whiteColor];
((UIImageViewInfo *) self.solutionPinSlots[counter])[email protected]"white";
}else{
((UIImageViewInfo *) self.solutionPinSlots[counter]).backgroundColor = [UIColor blackColor];
((UIImageViewInfo *) self.solutionPinSlots[counter])[email protected]"black";}
((UIImageViewInfo *) self.solutionPinSlots[counter]).hidden=NO;
((UIImageViewInfo *) self.solutionPinSlots[counter++]).alpha=1;
}
}
}];
[self.solutionPinSlots shuffle];
[self updateSolutionPinSlots];
}
-(void)function2{
NSString *obj;
for (int idx=0; idx< M;idx++) {
UIImageViewInfo *image = [[UIImageViewInfo alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]];
image.translatesAutoresizingMaskIntoConstraints=NO;
obj = (NSString *) [self.solutionPinSlots objectAtIndex:idx];
image.tag=2000*(self.brainController.slotsIndex+1)+idx;
image.hidden=NO;
image.alpha = 1;
if ([obj isEqualToString:@"clear"]) {
image.hidden=YES;
image.alpha = 0;
[email protected]"clear";
image.backgroundColor=[UIColor clearColor];
}else if ([obj isEqualToString:@"white"]){
[email protected]"white";
image.backgroundColor=[UIColor whiteColor];
}else if ([obj isEqualToString:@"black"]){
[email protected]"black";
image.backgroundColor=[UIColor blackColor];
}else{
NSLog(@"Something is Wrong!!!");
}
[self.solutionPinSlots replaceObjectAtIndex:idx withObject:image];
[self.view addSubview:image];
}
}
發佈您的描述方法的實現。 – bbum 2013-04-28 18:49:06
我沒有一個,我依靠在我的情況下是UIImageView的超類。 – mjeragh 2013-04-29 04:52:36