0 0

Iphone 坐标问题 在ImageView 上获取坐标10

我的程序 基于 Viewbased  Proj,在 View  里面 放了一个  ImageView 来显示图片 ,铺满
然后我将iphone 的显示
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);}
也就是倒过来, 然后点击图片来获取点击的位置,, 480X320
(当我点击图片的左边 那么图片就向前翻页,当我点击图片右边,图片就想后翻页,, ,我想用坐标来判断)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch    *touch = [[event touchesForView:self ] anyObject];
        CGPoint location = [touch locationInView:imageView];
       
        // right touch go to next image
        if(location.y>360.0){
                NSLog(@"right touch  %d",location.y);
                [imageView  removeFromSuperview];
                imageView =[[UIImageView alloc] initWithImage:[UIImage imageNamed:[imgArray objectAtIndex:0]]];
                [self.view addSubview:imageView];
        }
        /// left touch  back to previous image
        else if(location.y<120.0){
         NSLog(@"left touch  %d",location.y);
                [imageView  removeFromSuperview];
                imageView =[[UIImageView alloc] initWithImage:[UIImage imageNamed:[imgArray objectAtIndex:2]]];
                [self.view addSubview:imageView];
        }
       
}
複製代碼
通过Nslog 获取的信息是我的 坐标始终是 (0,0), 我到底哪里错了呢,, 清大家不吝赐教阿....

还有个问题 ::显示 倒置 之后,,坐标系统变了么 ? 480X320  还是  320X480
坐标的朝向 是 右下 还是左上 ?或者其他???
问题补充
有没有人阿,,帮我解决下阿,,,谢谢!
iOS 
2009年12月22日 21:23
目前还没有答案

相关推荐

Global site tag (gtag.js) - Google Analytics