ios - UIView 子类,触摸事件

标签 ios cocoa-touch uiview

我有一个 UIView 的子类.每当我检测到触摸事件时,我都需要显示一个新的 UI View 。

我知道我必须重写以下方法:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

我的问题是我不知道如何显示全屏 View 。

我尝试了以下方法:
CGRect screenSize = [[UIScreen mainScreen] bounds];
UIView *mysubview = [[UIView alloc] initWithFrame : screenSize];
[self.window addSubview:mysubview];

但我不确定这是否是正确的方法。

谁能给我建议?

最佳答案

在这种情况下,我使用 mySubView.frame = self.view.frame ;

关于ios - UIView 子类,触摸事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9410735/

相关文章:

ios - 没有互联网的 NSNotification

ios - 你如何在 Swift 中锁定一个线程?

ios - 未调用 UITableView 委托(delegate)方法

objective-c - Objective C 中的循环 #import/@class 问题

iphone - 设备方向改变时改变 UIImage

ios - Swift 3 UIView 动画

ios - Google+ iOS SDK 获取好友列表?

ios - 在没有 AFNetworking 的情况下安装 RestKit

iphone - 如何将附件 View 背景设置为与 UItableViewCell 中的内容 View 相同的背景?

ios - 将 subview 添加到 self.tableView.tableHeaderView 不起作用