Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 基于嵌入到UIScrollView中的UIImageView上的触摸坐标关闭UIScrollView_Iphone_Ios_Objective C - Fatal编程技术网

Iphone 基于嵌入到UIScrollView中的UIImageView上的触摸坐标关闭UIScrollView

Iphone 基于嵌入到UIScrollView中的UIImageView上的触摸坐标关闭UIScrollView,iphone,ios,objective-c,Iphone,Ios,Objective C,有一个带有许多照片的UITableView。点击照片时,会显示带有UIScrollView的modalView,其中还嵌入了UIImageView。点击的图像显示在这里(类似于Facebook应用程序)。 现在,我可以使用touchesMoved和CGRectMake垂直移动图像。 我想要实现的是,当我垂直拖动图像时,当达到某个阈值时,ImageView&ScrollView应该消失,我们应该回到tableView 使用以下方式移动图像: - (void) touchesMoved:(NSSet

有一个带有许多照片的
UITableView
。点击照片时,会显示带有
UIScrollView
modalView
,其中还嵌入了
UIImageView
。点击的图像显示在这里(类似于Facebook应用程序)。 现在,我可以使用
touchesMoved
CGRectMake
垂直移动图像。 我想要实现的是,当我垂直拖动图像时,当达到某个阈值时,ImageView&ScrollView应该消失,我们应该回到tableView

使用以下方式移动图像:

- (void) touchesMoved:(NSSet *)touches
        withEvent:(UIEvent *)event {
    UITouch * touch = [touches anyObject];
    CGPoint pos = [touch locationInView: [UIApplication sharedApplication].keyWindow];
    NSLog(@"%f", pos.y);

if (pos.y>50&&pos.y<430){
    [UIView setAnimationDelay:0];

    [UIView animateWithDuration:0.4

                     animations:^{_photoImageView.frame=CGRectMake(0,pos.y-100,320,200);}

                     completion:^(BOOL finished){ }];
}
}
-(无效)触摸移动:(NSSet*)触摸
withEvent:(UIEvent*)事件{
UITouch*touch=[触摸任何对象];
CGPoint pos=[touch locationInView:[UIApplication sharedApplication].keyWindow];
NSLog(@“%f”,位置y);

如果(pos.y>50和&pos.y>50和&pos.y解散
dismissModalViewControllerAnimated:
(应使用更新的方法
dismissViewControllerAnimated:completion:

(这是假设您演示了
presentModalViewController:animated:
,仅向屏幕添加视图不是模式演示)。如果您没有真正演示模式,则只需使用
removeFromSuperview


当以模式显示视图时,下面的视图将从显示中删除(预计不可见),因此如果将模式视图设置为透明,则其下方将显示黑色。如果要使覆盖视图透明,则应将其设置为子视图,设置不透明度(
alpha
)并使用
将子视图带到前台:

是否添加UIView或UIViewController[view removeFromSuperView];您没有在视图是滚动视图的地方尝试此操作,我已经尝试过了。我想我是错放了“removeFromSuperView”,或者使用了错误的视图实例。希望找到替代解决方案。[PS.基于FacebookSDK.framework的项目。]如果由我决定,我只会使用子视图。我对使用情态动词有偏见。它们缺乏所需的灵活性。
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch * touch = [touches anyObject];
CGPoint pos = [touch locationInView: [UIApplication sharedApplication].keyWindow];

if (pos.y>50&&pos.y<430){
    [UIView setAnimationDelay:0];

    [UIView animateWithDuration:0.4

                     animations:^{_photoImageView.frame=CGRectMake(0,140,320,200);}

                     completion:^(BOOL finished){ }];
}
else if(pos.y<50||pos.y>430)
    //Code needed here !!
    ;
}