나는 그가 만졌을 때만 류를 애니메이션으로 만들려고함으로써 튜토리얼을 확장하려고 시도해왔다. 그러나 터치는 등록되지도 않았고 하위 뷰인 것과 관련이 있다고 생각합니다. 여기 내 코드는 다음과 같습니다.하위 뷰를 터치했는지 확인하려면 어떻게합니까?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
if([touch view] == ryuView){
NSLog(@"Touch");
} else {
NSLog(@"No touch");
}
}
-(void) ryuAnims{
NSArray *imageArray = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
[UIImage imageNamed:@"4.png"],
[UIImage imageNamed:@"5.png"],
[UIImage imageNamed:@"6.png"],
[UIImage imageNamed:@"7.png"],
[UIImage imageNamed:@"8.png"],
[UIImage imageNamed:@"9.png"],
[UIImage imageNamed:@"10.png"],
[UIImage imageNamed:@"11.png"],
[UIImage imageNamed:@"12.png"],
nil];
ryuView.animationImages = imageArray;
ryuView.animationDuration = 1.1;
[ryuView startAnimating];
}
-(void)viewDidLoad {
[super viewDidLoad];
UIImageView *image = [[UIImageView alloc] initWithFrame:
CGRectMake(100, 125, 150, 130)];
ryuView = image;
ryuView.image = [UIImage imageNamed:@"1.png"];
ryuView.contentMode = UIViewContentModeBottomLeft;
[self.view addSubview:ryuView];
[image release];
}
이 코드는 잘 컴파일되지만, ryu를 만지거나 클릭하면 아무런 변화가 없습니다. 또한
if([touch view] == ryuView.image)
을 시도했지만 그 날이 오류를 제공합니다. " '* 구조체있는 UIImage'뚜렷한 목표 - C 형의 비교와 '구조체있는 UIView *'캐스트 부족" 내가 도대체 뭘 잘못하고있는 겁니까?