我有 2 个形状(图 1),需要找到它们组合的一个凸包(图 2)。更准确地说,我有兴趣获得外角(紫色圆圈图 2)。形状是分离的。我描绘的形状是一块方形的透明塑料片,侧面有两种颜色的条纹。条纹非常容易追踪(在范围内)。
我想到的一种快速而肮脏的方法是用白线连接条纹的中心,然后获得凸包。我也在考虑连接两个形状的顶点列表并获得组合的凸包,但我不确定这种方法是否会使凸包函数崩溃。
有没有更优雅的方法来解决这个问题?
请帮忙
图1
图2
现在我创建如下(我的file.h):
UIImageView *pic1, *pic2, *pic3, *pic4, *pic5, *pic6, *pic7, *pic8, *pic9, *pic10;
Then in my (file.m):
UIImageView *pic1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”picName.png”]];
UIImageView *pic2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”picName.png”]];
……
UIImageView *pic10 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”picName.png”]];
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我需要UIImageView的许多实例(由其他因素触发的数字).
有没有办法在我的file.m中自动创建多个UIImageView实例,不知何故如下?:
for (int x; (x=10); x++)
{
UIImageView * pic[x] = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myPic.png"]];
}
Run Code Online (Sandbox Code Playgroud)
这个例子不起作用,但我想展示我想要编程的内容.
我试图建立我的自定义SEGUE,在行为标准推SEGUE相似,但在我的情况下,我想使用自定义按钮屏幕间切换(无标签栏会适合这个应用程序,任何模式赛格瑞是没有好或者) .主屏幕是自定义图形,屏幕是一个地图.用户选择地图上的点,点击完成并返回主屏幕及其坐标.我正在尝试将ViewControllers与自定义segue连接起来.
我在互联网上研究了很多解决方案并找到了一个可以适应的解决方案,但代码分散在ViewControllers和AppDelegate周围(我不确定Apple是否会接受它).我正在尝试将整个代码放到CustomSegue.m/h.成功是部分的,因为使用技术(下面)它会分割到第二个ViewControler,但我无法弄清楚如何解除第二个并回到主屏幕.我尝试了各种技术,但是当我运行它时,编译器会终止带有大量错误的应用程序.在构建和运行之前既没有错误也没有警告.我还尝试使用[self dismissModalViewControllerAnimated:YES]按钮解除它; 或[self dismissViewControllerAnimated:YES completion:nil]; 当我尝试模态segues但我的代码结果不好时,它们会工作.
有没有人有一个简洁的方法来做这个.我在最近几天堆积了这个问题.我看到很多应用程序中的那种segues转换,所以它似乎非常流行,简单的解决方案.我对Xcode只有几个月的经验不多.这是我的自定义segue(使用QuartzCore动画).
#import "CustomTabBarSegue.h"
@implementation CustomTabBarSegue
-(void)perform {
UIViewController *src = (UIViewController*)[self sourceViewController];
UIViewController *dst = (UIViewController*)[self destinationViewController];
UIView *currentView = src.view;
UIView *theWindow = [currentView superview];
UIView *newView = dst.view;
[theWindow addSubview:newView];
CATransition *transition = [CATransition animation];
transition.delegate = self;
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;
[[theWindow layer] addAnimation:transition forKey:@"MySegue"];
}
@end
Run Code Online (Sandbox Code Playgroud)
下面是来自destinationVC的我的按钮的代码.(不起作用)
- (IBAction)dismiss:(id)sender
Run Code Online (Sandbox Code Playgroud)
{
[self dismissViewControllerAnimated:YES completion:^() {
[self performSegueWithIdentifier:@"MySegue" sender:self];
}];
Run Code Online (Sandbox Code Playgroud)
}
ios ×2
iphone ×2
back-button ×1
c++ ×1
ipad ×1
objective-c ×1
opencv ×1
python ×1
segue ×1
xcode ×1