버튼을 클릭 할 때 아이폰에서 터치 이벤트를 호출해야합니다. 다음 코드는 터치 이벤트를 호출하지 않습니다버튼을 클릭 할 때 아이폰 터치 이벤트를 호출 할 수 없습니다
이 문제를 해결하는 방법을 알려주십시오.
버튼 코드는 다음과 같습니다.
- (공극) 방법 {
BottomView = [UIView의 ALLOC] INIT];
btnRefresh = [UIButton buttonWithType : UIButtonTypeCustom]; [btnRefresh setImage : [UIImage imageNamed : @ "refresh_icon.png"] forState : UIControlStateNormal]; [str : UIControlStateNormal]; [btnRefresh setBackgroundImage : [[UIImage imageNamed : @ "ggrey1.png"] stretchableImageWithLeftCapWidth : 12.0 topCapHeight : 0.0] forState : UIControlStateHighlighted]; [btnRefresh setBackgroundImage : [[UIImage imageNamed : @ "ggrey1.png"] stretchableImageWithLeftCapWidth : 12.0 topCapHeight : 0.0] forState : UIControlStateSelected]; [btnRefresh addTarget : 자기 액션 : @selector (KeyboardRefresh :) forControlEvents : UIControlEventTouchUpInside];
[btnRefresh setUserInteractionEnabled : YES]; [btnRefresh setMultipleTouchEnabled : YES];
[BottomView addSubview:btnRefresh];
경우 (self.isPortrait) {
[btnRefresh setFrame:CGRectMake(71, 0, 40, 6)];
[BottomView setFrame:CGRectMake(0, 160, 320, 41)];
}
else{
[btnRefresh setFrame:CGRectMake(94, 0, 61, 8)];
[BottomView setFrame:CGRectMake(0, 123, 480, 41)];
}
}
상기 Methos는 호출되고
- (무효) touchesBegan : (NSSet *)는 withEvent 접촉 : (UIEvent *) 이벤트
{ NSLog (@ "예"); }
은 새로 고침 버튼을 클릭 할 때 호출되지 않습니다.
누구든지 나를 도와 줄 수 있습니다. 미리 감사드립니다.
감사합니다. 하지만 둘 다 호출해야하고 내가 터치 감동을 호출하고 끝을 만지는 것이 필요합니다. 새로 고침 버튼을 클릭 할 때 다른 버튼을 보여야합니다. – Ganesh
잘 모르겠지만 버튼에 대해 걱정한다면 아마도 여러 주마다 여러 가지 방법을 만들고 싶을 것입니다. UIControlEventTouchUpInside –