Iphone UIButton不接收点击

Iphone UIButton不接收点击,iphone,objective-c,cocoa-touch,uibutton,Iphone,Objective C,Cocoa Touch,Uibutton,这就是我的代码: UIButton *svObjectButton = [UIButton buttonWithType:UIButtonTypeCustom]; svObjectButton.frame = CGRectMake(0, 0, 100, 100); [svObjectButton addTarget:self action:@selector(svObjectTouchUpInside) forControlEvents:UIControlEventT

这就是我的代码:

    UIButton *svObjectButton = [UIButton buttonWithType:UIButtonTypeCustom];

    svObjectButton.frame = CGRectMake(0, 0, 100, 100);

    [svObjectButton addTarget:self action:@selector(svObjectTouchUpInside) forControlEvents:UIControlEventTouchUpInside];       
    [svView addSubview:svObjectButton];

    UIButton *removeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    removeButton.frame = CGRectMake(0, 0, 20, 20);
    [removeButton addTarget:self action:@selector(removeButtonPressed) forControlEvents:UIControlEventTouchUpInside];
    [svObjectButton addSubview:removeButton];
    [svObjectButton bringSubviewToFront:removeButton];
但由于某些原因,所有对removeButton的点击都会直接进入svObjectButton


有什么想法吗?

为什么removeButton必须是svObjectButton的子视图


我认为问题在于UIButton是UIButton的子视图。尝试将removeButton添加到svView。

我希望,您是在另一个大按钮上添加一个小按钮……为了实现这一点,您可以添加 一个UIView(例如buttonView)在svView上具有大的按钮框大小。之后,您可以在buttonView(UIView)上添加两个按钮。您必须避免

            [svObjectButton addSubview:removeButton];