- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我创建了一个 Diagonal UIView,在所有四个边的所有角和中心都有八个 subview 。
所有红点都可以拖动以调整菱形的大小。
所有 subview 在对角线 UIView 中添加一次,参见图像 Screen1..
现在我不想通过 Diamond View 的框架,所以它可以用中心和红点的框架来管理。我需要使用 Autoresizemask 进行管理,因此我不需要在增加或减少时传递每个时间范围。
这里是为菱形创建红点的代码..
view4 = [[CustomDotRD alloc] initWithFrame:CGRectMake(self.frame.size.width - self.frame.size.width/4 - RED_W_H_RD/2, self.frame.size.height - self.frame.size.height/4 - RED_W_H_RD/2, RED_W_H_RD, RED_W_H_RD)];
view4.backgroundColor = [UIColor clearColor];
UIPanGestureRecognizer *panGestureDiamond = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(singleFingerTapsDiamond:)];
[view4 addGestureRecognizer:panGestureDiamond];
[panGestureDiamond release];
[view4 setContextPropertyColor:RGB_RED contextFrame:CGRectMake(RED_W_H/2, RED_W_H/2, RED_W_H, RED_W_H) index:4 tag:kTAG_D4];
view4.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
view4.center = CGPointMake(self.frame.size.width - self.frame.size.width/4, self.frame.size.height - self.frame.size.height/4);
[self addSubview:view4];
[self.boundDiamondArray addObject:view4];
我在这里发布了一些图片,同时增加了菱形,一些红点有奇怪的行为..
这里是在 Screen2 中看到的所有红点的所有自动调整大小掩码的列表。
1 - BottomMargin , LeftMargin , RightMargin
2 - TopMargin , BottomMargin , LeftMargin , RightMargin
3 - TopMargin , BottomMargin , LeftMargin
4 - TopMargin , BottomMargin , LeftMargin , RightMargin
5 - TopMargin , LeftMargin , RightMargin
6 - TopMargin , BottomMargin , LeftMargin , RightMargin
7 - TopMargin , BottomMargin , RightMargin
8 - TopMargin , BottomMargin , LeftMargin , RightMargin
四个角的红点工作正常..但是四个中心边缘的红点不能正常工作..让我展示一些屏幕..
让我知道您解决这个问题的想法..
请记住,我不想传递任何框架或中心,只需使用 Autoresize Mask 进行管理。 .
了解 AutoresizeMask 的有用链接 Link .
问候,
最佳答案
由于红点的高度,边缘中心的点的 topMargin/bottomMargin 比率不正好为 3,因此自动调整大小对您不起作用。如果点的宽度和高度为零,它就会正确定位。
我认为实现 layoutSubviews
方法会是您任务的更好解决方案。
如果你真的想只使用 autoresizingMask
来解决这个问题。您需要将每个红点放在大小为零的 View 中,并将大小为零的 View 添加到菱形 View 中。使用下面的代码代替您提供的代码。您可能需要对其他部分进行一些更改,因为这些点不再是钻石的直接 subview 。
view4 = [[CustomDotRD alloc] initWithFrame:CGRectMake(-RED_W_H_RD/2, -RED_W_H_RD/2, RED_W_H_RD, RED_W_H_RD)];
view4.backgroundColor = [UIColor clearColor];
UIPanGestureRecognizer *panGestureDiamond = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(singleFingerTapsDiamond:)];
[view4 addGestureRecognizer:panGestureDiamond];
[panGestureDiamond release];
[view4 setContextPropertyColor:RGB_RED contextFrame:CGRectMake(RED_W_H/2, RED_W_H/2, RED_W_H, RED_W_H) index:4 tag:kTAG_D4];
UIView* dotView4 = [[CustomView alloc] initWithFrame:CGRectZero];
dotView4.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
dotView4.center = CGPointMake(self.frame.size.width - self.frame.size.width/4, self.frame.size.height - self.frame.size.height/4);
[dotView4 addSubview:view4];
[self addSubview:dotView4];
[dotView4 release];
[self.boundDiamondArray addObject:view4];
要解决触摸事件问题,您应该重写 CustomView
类中 UIView
的 pointInside:withEvent:
方法。以下代码将确保触摸事件到达 subview ,即使触摸点在 View 边界之外也是如此。
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
for(UIView* aView in self.subviews){
CGPoint localPoint = [self convertPoint:point toView:aView];
if([aView pointInside:localPoint withEvent:event]){
return YES;
}
}
return NO;
}
关于iphone - 使用增加的框架自动调整蒙版大小问题 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12216631/
从开发者的角度来看,Mac 版 Safari 和 Windows 版 Safari 有何不同? 我认为可以归结为评估两者之间的差异(如果我遗漏了什么,请更正): - 布局渲染 - Javascript
正如标题所说:Android 版 Chrome 和 iOS 版 Chrome 有什么区别。 我对两者进行了一些研究,但找不到关于该主题的任何最新信息。进行这项研究的原因是因为我正在研究某些 Web A
我有以下脚本可以获取您的地理位置并重定向您到 Google map : (function(){ navigator.geolocation.getCurrentPosition(function(p
我负责修复导航栏显示比应有的低 1 像素的问题。 查看网站后,我无法找到所报告的问题,直到我在 Mac 上进行了检查。 Firefox、Safari 等在 Mac 上运行良好,但 Chrome 是导致
我是典型的 .NET 开发人员(C# 是我的第一语言),几年前转向 ASP.NET MVC。现在是我职业生涯发生重大变化的新时期。如果我们看看 Web 开发的前景,我们可以看到新技术如何占领世界,而其
Grails 2.0 项目目前带有资源插件 1.1.5,它似乎有几个依赖问题(例如,参见 this post 的答案)。我正在使用 IntelliJ,虽然我将 BuildConfig.groovy 更
我有一个支持 android 2.3.3 的 android 项目。 但它也支持 sdk 版本 17。当我创建一个新 Activity 时,它会创建一个特定于版本 17 的 Activity 。 如何
有没有人有在 Android 设备上使用 pjsip 的经验?我看到几个非商业/测试项目使用它,所以我假设它可以完成,但没有一个有很好的记录。我认为 pjsip-jni 项目是一个不错的起点,但基本上
谁能告诉我在 Xcode (iPhone) 中执行以下操作的最佳方法是什么。 我有一个主导航屏幕,上面有一些按钮。当用户单击任何按钮时,他们将被带到带有更多选项按钮的子导航屏幕。在这里,他们单击任意一
我正在使用 JBoss Embedded beta3.SP10 版本,我正面临一个应该在某些 Hibernate 版本中修复的持久性错误。可悲的是,我不知道我的 JBoss Embedded 中使用的
我想在 android 中使用简单的 snmp get。我找到了 java 的代码并尝试在 android 中使用它。我还附加了 snmp4j.jar 文件用于 android。但是我得到了 Null
我的实现目标是: 可以通过一个或多个关键词搜索到文章。 可以通过文章的关键词列表查询到其相关文章。 查询到的结果依据相关程度降序排列。 查询速度要够快。(理论上关键词检索比全文检索要快很多的
我正在尝试创建一个允许我将视频从 iPhone 流式传输到服务器的应用程序。我目前关于如何做到这一点的理论是创建一系列 FFMpeg 文件并将它们发送到服务器。据我所知,我已经编译了 FFMpeg图书
这个问题在这里已经有了答案: Login failed in github for window (5 个回答) 7年前关闭。 当我安装 GitHub 时,我无法使用我的帐户凭据登录。 我收到错误 L
我需要在我的 iPad 项目中使用 Three20。我想知道 iPhone 版本的 Three20 项目是否可以直接在 iPad 上使用,还是应该等待这个时间线完成: http://three20.i
有人能做到吗 http://www.surina.net/soundtouch/适用于 iPhone? 简单的 Xcode 演示会很有帮助。 我只想通过一些音调操作来播放音效。谢谢克里斯 最佳答案 使
如何在iPhone中使用“speex”进行音频编码/解码?我没有在项目中添加框架。 最佳答案 这个blog entry: Compile Speex For iPhone克利夫顿·克雷格(Clifto
我想知道bonjour是公共(public)API还是私有(private)API?我们可以直接在我们的应用程序中使用它吗? 最佳答案 Bonjour 由 NSNetServices 和 CFNetS
••••• 已解决•••••该应用程序可用。只是花了一些时间才出现。我之所以将其视为测试版,是因为我的 Google 帐户用于 alpha 测试。如果您遇到同样的问题,只需从测试人员中删除您的帐户并等
我是 Android 编程初学者。 我在使用 Android 下载文件时遇到问题 我使用了 Httpost、Httpget 和 hhtpurlconnection前两个根本不起作用第三个两次无法下载
我是一名优秀的程序员,十分优秀!