每次点击时如何进行绘制圆点形状的动作

时间:2011-05-22 13:26:06

标签: iphone xcode4 drawing

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

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

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

每次点击我的UIImageView

时,我都需要一个绘制圆点形状的动作
-(IBAction)drawdot:(id)sender{}

感谢

到目前为止我得到了什么:

基本上我有一个滚动视图,上面有一些按钮,在滚动视图的底部我添加了一个UIImageView,我想用手指写。 因为scrolView很难,所以我不得不添加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识别为多次点击..

感谢

1 个答案:

答案 0 :(得分:2)

您没有采用非常现实的方法来学习如何为给定平台开发软件。您尝试了什么(超出空方法)?你在庞大的Cocoa文档中读到了什么?

你的目标:一个UIView响应触摸事件,找出它们的坐标,并将自己标记为需要显示,然后(在其绘制例程中由操作系统调用,如果适当的话)绘制一些形状。

Apple的文档中有几个主要的,引人注目的开发人员指南,涉及responding to touch eventsdrawing。所有这些都在基本的“入门”材料中引用。你读过它们吗?你至少撇去过它们吗?如果你有,你不明白什么/你被困在哪里?如果还没有,你应该调整你的期望:阅读文档并提出更具体的问题,比如其他人。

如果您没有显示出至少一些努力,那么您的问题最有可能被完全忽略。