iOS无法通过按按钮对象移动视图
我对视图对象有问题。如果触摸按钮A或B并移动,我想移动父视图。 但当按下按钮时,它应该像往常一样工作-只是(iAction)ABtnPressed:(id)发送器功能iOS无法通过按按钮对象移动视图,ios,view,touchesmoved,Ios,View,Touchesmoved,我对视图对象有问题。如果触摸按钮A或B并移动,我想移动父视图。 但当按下按钮时,它应该像往常一样工作-只是(iAction)ABtnPressed:(id)发送器功能 ---------------------- | | | Parent View | | | | | | | |
----------------------
| |
| Parent View |
| |
| |
| |
| |
| ________________ |
| | Another view | |
| | ------ ------ | |
| | | A | | B | | |
| | ------ ------ | |
| |________________| |
|____________________|
我是如何做到的:
-(无效)触摸移动:(NSSet*)触摸事件:(UIEvent*)事件
{
NSSet*AllTouchs=[event AllTouchs];
UITouch*touch=[[AllTouchs AllObject]对象索引:0];
CGPoint-touchLocation=[touch-locationInView:self.view]
if (touch.view == AnotherView) // It's work properly
{
ParentView.center = CGPointMake(ParentView.center.x, touchLocation.y);
}
if (touch.view == AButton) // It's **NOT** work properly
{
ParentView.center = CGPointMake(ParentView.center.x, touchLocation.y);
}
请帮助我,我如何解决这个问题。我刚刚开始为iOS开发。因为UIButton有自己的触摸事件,它不会监听普通触摸代理,您必须使用UIGestureRecograins,添加两个按钮,并像普通选择器一样查看
祝你好运我已回复了你的邮件。