UIbutton *button = [UIbutton buttonWithType:UIbuttonTypeCustom];[button addTarget:self action:@selector(imagetouch:withEvent:) forControlEvents:UIControlEventtouchDown];[button addTarget:self action:@selector(imageMoved:withEvent:) forControlEvents:UIControlEventtouchDragInsIDe];[button setimage:[UIImage imagenamed:@"vehicle.png"] forState:UIControlStatenormal];[self.vIEw addSubvIEw:button];
然后你可以通过响应UIControlEventtouchDragInsIDe事件,将车辆移动到任何你想要的地方,例如:
- (IBAction) imageMoved:(ID) sender withEvent:(UIEvent *) event{ CGPoint point = [[[event alltouches] anyObject] locationInVIEw:self.vIEw]; UIControl *control = sender; control.center = point;}
对于个人车辆来说,处理自己的拖动更容易,与整个场景管理相比。
总结以上是内存溢出为你收集整理的iphone – 在iOS中的基本拖放全部内容,希望文章能够帮你解决iphone – 在iOS中的基本拖放所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)