我在ViewDidLoad上有一个带有此代码的视图控制器...
UIImage *imageU = [[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"transparent" ofType:@"png"]];
TouchImageView *transparent = [[TouchImageView alloc] initWithImage:imageU];
[transparent setUserInteractionEnabled: YES];
[transparent setMultipleTouchEnabled: YES];
[self.view addSubview:transparent];
imageU = [[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pointer" ofType:@"png"]];
myPointer = [[UIImageView alloc]initWithImage:imageU];
[myPointer setUserInteractionEnabled: YES];
myPointer.center = CGPointMake(160, 240);
[self.view addSubview: myPointer];
正如您所见,透明的类是TouchImageView,它是UIImageView的子类。
我需要的是,TouchImageView类中生成的事件必须控制“指针”的位置,这是该类范围之外的对象。
如您所见,透明和指针在层次上都处于同一级别。
如何引用TouchImageView类中的指针?
我正努力做的工作是
self.superview.myPointer.transform = CGAffineTransformConcat(originalTransform, incrementalTransform);
但它说myPointer不是结构或联合......
答案 0 :(得分:1)
尝试使myPointer成为TouchImageView类的实例变量