如何做出每次点击时都会绘制点形状的动作

发布于 2024-11-09 04:06:19 字数 2242 浏览 0 评论 0原文

如果您想要的话,您可以尝试我的应用程序,这是 2 个促销代码: JMYMRWL4AXX7 4ATFK6XWAWXL

http://itunes.apple.com/us/app/ianamnesi/ id426778210?mt=8

我想改进它,所以基本上我希望能够用手指在滚动视图上的 UIImageView 上进行签名

我需要一个每次点击时绘制点形状的动作我的 UIImageView

-(IBAction)drawdot:(id)sender{}

感谢

我到目前为止所得到的:

基本上我有一个滚动视图,上面有一些按钮,在滚动视图的底部我添加了一个 UIImageView,我想用手指写字。 因为scrollView很难,所以我不得不添加 UILongPressureGesturesRecongnizer:

- (void)viewDidLoad {
[scrollView setScrollEnabled:YES];
[scrollView setContentSize:CGSizeMake(320,1540)];

scrollView.clipsToBounds = YES;
scrollView.userInteractionEnabled = YES;
scrollView.delaysContentTouches = YES;
scrollView.canCancelContentTouches = NO;

UILongPressGestureRecognizer *gestureRec = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
((UILongPressGestureRecognizer*)gestureRec).minimumPressDuration = 0.5;
((UILongPressGestureRecognizer*)gestureRec).numberOfTouchesRequired = 1;
(( UILongPressGestureRecognizer*)gestureRec).allowableMovement = NO;
[drawImage addGestureRecognizer:gestureRec];

[gestureRec release];  

[super viewDidLoad];
mouseMoved = 0;
mouseSwiped = YES;

if ([MFMailComposeViewController canSendMail])
    button.enabled = YES;


UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(printItem) forControlEvents:UIControlEventTouchDown];
btn.frame = CGRectMake(75, 0, 44, 44);

[btn setImage:[UIImage imageNamed:@"print.png"] forState:UIControlStateNormal]; [self.view addSubview:btn];

现在

我的 UIIMageView 识别长触摸,所以当我触摸 0.5 秒时,它会执行此操作:

- (void)imageTapped:(UITapGestureRecognizer *)sender
{
UIView *theSuperview = self.view; // whatever view contains your image views
CGPoint touchPointInSuperview = [sender locationInView:theSuperview];
UIView *touchedView = [theSuperview hitTest:touchPointInSuperview withEvent:nil];
if([touchedView isKindOfClass:[drawImage class]])
{
    // action for making a dot 
}

}

现在我必须包含一些在我点击时生成点的内容,并且因为 longPressureGestureRecognize 当我移动手指时它会将其识别为多次点击..

谢谢

you can try my app if you want this are 2 promo codes:
JMYMRWL4AXX7
4ATFK6XWAWXL

http://itunes.apple.com/us/app/ianamnesi/id426778210?mt=8

I want to improve it with, so basically I want to be able to do the signature with the finger on the UIImageView on the scrollView

I need an action that draws a dot shape every time I tap on my UIImageView

-(IBAction)drawdot:(id)sender{}

thanks

what I got so far:

basically I have a scrollview with some buttons on it and on the bottom of the scrollview I added an UIImageView, were I want to write with fingers.
Because the scrolView is difficult, so I had to add UILongPressureGesturesRecongnizer:

- (void)viewDidLoad {
[scrollView setScrollEnabled:YES];
[scrollView setContentSize:CGSizeMake(320,1540)];

scrollView.clipsToBounds = YES;
scrollView.userInteractionEnabled = YES;
scrollView.delaysContentTouches = YES;
scrollView.canCancelContentTouches = NO;

UILongPressGestureRecognizer *gestureRec = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
((UILongPressGestureRecognizer*)gestureRec).minimumPressDuration = 0.5;
((UILongPressGestureRecognizer*)gestureRec).numberOfTouchesRequired = 1;
(( UILongPressGestureRecognizer*)gestureRec).allowableMovement = NO;
[drawImage addGestureRecognizer:gestureRec];

[gestureRec release];  

[super viewDidLoad];
mouseMoved = 0;
mouseSwiped = YES;

if ([MFMailComposeViewController canSendMail])
    button.enabled = YES;


UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:self action:@selector(printItem) forControlEvents:UIControlEventTouchDown];
btn.frame = CGRectMake(75, 0, 44, 44);

[btn setImage:[UIImage imageNamed:@"print.png"] forState:UIControlStateNormal];
[self.view addSubview:btn];

}

now my UIIMageView recognise the long touch, so when I touch for 0.5 sec it make this action:

- (void)imageTapped:(UITapGestureRecognizer *)sender
{
UIView *theSuperview = self.view; // whatever view contains your image views
CGPoint touchPointInSuperview = [sender locationInView:theSuperview];
UIView *touchedView = [theSuperview hitTest:touchPointInSuperview withEvent:nil];
if([touchedView isKindOfClass:[drawImage class]])
{
    // action for making a dot 
}

}

now I had to include something that makes dot when I tap, and because the longPressureGestureRecognize when I move the finger it recognise it as multiple taps..

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟火散人牵绊 2024-11-16 04:06:19

您没有采取非常现实的方法来学习如何为给定平台开发软件。您尝试过什么(除了空方法之外)?您在大量的 Cocoa 文档中读到了什么?

您的目标:一个 UIView 响应触摸事件,计算出它们的坐标,并将自身标记为需要显示,然后(在适当的情况下由操作系统调用的绘图例程中)绘制一些形状。

Apple 文档中有几个主要的、备受瞩目的开发人员指南,涉及 响应触摸事件 并使用 绘图< /a>.所有这些都在基本“入门”材料中引用。你读过它们吗?你至少浏览过它们吗?如果你有,你有什么不明白/你在哪里陷入困境?如果还没有,您应该调整您的期望:阅读文档并像其他人一样提出更具体的问题。

如果您不付出任何努力,您的问题很可能会被完全忽略。

You're not taking a very realistic approach toward learning how to develop software for a given platform. What have you tried (beyond an empty method)? What have you read in the vast Cocoa documentation?

Your goal: A UIView that responds to touch events, figures out their coordinates, and flags itself as needing to display, then (in its drawing routine that is called by the OS if and when appropriate) draws some shape.

There are several major, high-profile developer guides in Apple's documentation that deal with responding to touch events and with drawing. All of these are referenced in the basic "getting started" material. Have you read them? Have you at least skimmed them? If you have, what didn't you understand / where did you get stuck? If you haven't, you should adjust your expectations: read the documentation and ask more specific questions like everybody else.

Without displaying at least some effort on your part, your questions are most likely to be ignored entirely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文