다음과 같은 viewcontroller가 있습니다. 하지만 터치가 발견되었습니다. 누구든지 무엇이 잘못되었는지 말해 줄 수 있습니까?touchesBegan이 감지되지 않습니다.
- (id)init
{
if (self = [super init])
self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
return self;
}
-(void) viewWillAppear:(BOOL)animated
{
overlay = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"overlay.png"]] autorelease];
[self.view addSubview:overlay];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// Detect touch anywhere
UITouch *touch = [touches anyObject];
// Where is the point touched
CGPoint point = [touch locationInView:self.view];
NSLog(@"pointx: %f pointy:%f", point.x, point.y);
// Was a tab touched, if so, which one...
if (CGRectContainsPoint(CGRectMake(1, 440, 106, 40), point))
NSLog(@"tab 1 touched");
else if (CGRectContainsPoint(CGRectMake(107, 440, 106, 40), point))
NSLog(@"tab 2 touched");
else if (CGRectContainsPoint(CGRectMake(214, 440, 106, 40), point))
NSLog(@"tab 3 touched");
}
UIView 하위 클래스를 만드는 방법을 알려주시겠습니까 – Muniraj
Apple docs에서 이것에 대해 살펴보십시오. 그것은 또한 당신이 tabbar를 사용하려고하는 것처럼 보입니다. 너는 너 자신 터치의 위치를 확인하지 않는다. 각각의 'UIView'하위 클래스가이를 지원합니다. 실제로는 위의 코드는 재생중인 영화에 오버레이 이미지를 생성하는 것입니다 : http://developer.apple.com/iphone/library/navigation/index.html – bddckr
사실 위 코드는 재생중인 영화에 오버레이 이미지를 생성하는 코드입니다. 그 이유는 tabbar 대신 위치를 확인해야합니다. u는보기를 서브 클래스하고 거기에 터치를 감지하지 않는 한 유 ... 영화 일을 통해 터치를 감지 할 수있는 경우 – Muniraj