问题是我必须触摸两次才能拖动按钮..当我第一次触摸时,它会自动复制按钮并触摸结束..现在我想要的是第一次触摸并拖动..
point = [[[event allTouches] anyObject] locationInView:self.view];
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:(id)touch];
UIButton * anotherButton =(id) [NSKeyedUnarchiver unarchiveObjectWithData:archivedData];
UIImage *senderImage=[(id)touch imageForState:UIControlStateNormal];
CGImageRef cgImage = [senderImage CGImage];
UIImage *copyOfImage = [[UIImage alloc] initWithCGImage:cgImage];
[anotherButton setImage:copyOfImage forState:UIControlStateNormal];
[anotherButton addTarget:self action:@selector(wasDragged:withEvent:)forControlEvents:UIControlEventTouchDragInside];
[self.view addSubview:anotherButton];