【发布时间】:2014-05-27 13:49:34
【问题描述】:
我正在尝试将一张图片全屏显示并打开按钮来执行操作。
这是我的结果截图:
我的问题是第一行(最高)的按钮不可触摸。 顶部布局似乎没有任何动作。
这是我的代码:
- (void)showActionsForGlobalFullScreen:(UIGestureRecognizer *)gestureRecognizer {
//LEFT
UIImage* cancelImage = [UIImage imageNamed:@"cancel.png"];
CGRect frameimg = CGRectMake(3, 3, cancelImage.size.width, cancelImage.size.height);
UIButton *cancelButton = [[UIButton alloc] initWithFrame:frameimg];
UIImage* flagImage = [UIImage imageNamed:@"flag.png"];
CGRect frameimg2 = CGRectMake(3, 40, flagImage.size.width, flagImage.size.height);
UIButton *flagButton = [[UIButton alloc] initWithFrame:frameimg2];
[cancelButton addTarget:self action:@selector(closeFullView:) forControlEvents:UIControlEventAllTouchEvents];
[cancelButton setBackgroundImage:cancelImage forState:UIControlStateNormal];
[flagButton addTarget:self action:@selector(displayFlag:) forControlEvents:UIControlEventAllTouchEvents];
[flagButton setBackgroundImage:flagImage forState:UIControlStateNormal];
//RIGHT
UIImage *exitFullScreenImage = [UIImage imageNamed:@"exitFullScreen.png"];
CGRect frameimg3 = CGRectMake(fullScreenViewFromVC.frame.size.width - 25 , 3, exitFullScreenImage.size.width, exitFullScreenImage.size.height);
UIButton *exitFullScreenButton = [[UIButton alloc] initWithFrame:frameimg3];
UIImage *commentImage = [UIImage imageNamed:@"comment.png"];
CGRect frameimg4 = CGRectMake(fullScreenViewFromVC.frame.size.width - 25 , 40, commentImage.size.width, commentImage.size.height);
UIButton *commentButton = [[UIButton alloc] initWithFrame:frameimg4];
[exitFullScreenButton addTarget:self action:@selector(exitFullScreenPhoto:) forControlEvents:UIControlEventAllTouchEvents];
[exitFullScreenButton setBackgroundImage:exitFullScreenImage forState:UIControlStateNormal];
[commentButton addTarget:self action:@selector(diplayComments:) forControlEvents:UIControlEventAllTouchEvents];
[commentButton setBackgroundImage:commentImage forState:UIControlStateNormal];
//[actionsView addSubview:flagButton];
[fullScreenViewFromVC addSubview:cancelButton];
[fullScreenViewFromVC addSubview:flagButton];
[fullScreenViewFromVC addSubview:exitFullScreenButton];
[fullScreenViewFromVC addSubview:commentButton];
}
重要提示:
fullScreenViewFromVC 是一个扩展 UIView 的自己的类,并在我的控制器上实例化。
基本上我被称为UITableViewCell 上的图片中的全屏方法
我正在使用这个 fullScreenViewFromVC 变量将我的数据从当前选定的单元格存储到我的控制器。
感谢您的帮助。
【问题讨论】:
-
请提供您如何生成此接口的相关代码;事实上,没有足够的信息来正确诊断您的问题
-
表示只有一个
UIButton没有触发动作?并显示您的代码 -
你的按钮不是被iOS状态栏覆盖了吗?
-
我已经添加了我的代码,但它是一个基本的。在调用这个方法之前我已经完成了
[[UIApplication sharedApplication] setStatusBarHidden:YES]
标签: ios objective-c click fullscreen