【发布时间】:2014-04-16 07:01:48
【问题描述】:
我正在尝试让图像在点击时全屏显示,这听起来并不复杂。
检测到点击后它当前正在执行的工作:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
if (self.contentView.frame.origin.y >= 0 && CGRectContainsPoint(self.bottleImageView.frame, touchLocation)) {
[UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
[bottleImageView setFrame:[[UIScreen mainScreen] bounds]];
bottleImageView.backgroundColor = [UIColor blackColor];
}completion:^(BOOL finished){}];
...
}
虽然有问题。我需要将 UIImageView 放在前面,以便它在其他视图前面绘制图像。当我将[self.view bringSubviewToFront:bottleImageView]; 添加到组合中时(在动画块之前、完成块中或此代码之后),情况发生了变化。第一次点击时,UIImageView 背景变为黑色,第二次点击时视图扩展为全屏。
我确信这只是我忽略的一些小而愚蠢的事情。
编辑:我已经添加了触摸代码
编辑 (2): 我可能遗漏了一些重要信息。我想我会为这个项目尝试自动布局。我猜那里有什么东西不能让一切都按预期工作?
【问题讨论】:
-
你能发布你的点击检测代码,调用上面的代码吗?
标签: ios objective-c uiimageview