我正在开发一个小游戏,我想在超级视图上做一些功能..超级视图是一个自定义类,即反射视图..并且希望在用户移动视图时隐藏反射..
这是我所做的...... (查看代码中的评论以获取详细信息)
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
NSLog(@"Touch Began");
frame2 = dragImageView1.frame;
NSLog(@"uiview origin: %@", NSStringFromCGPoint(frame2.origin));
// here i want to get the superview Programatically because i will work on multiple such views and [touch view].superview does not give me the ReflectionView Functions
[_reflectionView1 hideReflection];
UITouch *touch = [[event allTouches] anyObject];
if ([[touch view] tag]!=0) {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[[touch view] setFrame:CGRectMake(frame2.origin.x, frame2.origin.y, 125.0 * 1.1, 135.0 * 1.1)];
} else {
[[touch view] setFrame:CGRectMake(frame2.origin.x, frame2.origin.y, 52.08 * 1.1, 63.28 * 1.1)];
}
[self.view bringSubviewToFront:[touch view].superview];
}
}