0
@interface OOTRotaryWheel : UIControl


@property (weak) id <OOTRotaryProtocol> delegate;
@property (nonatomic, strong) UIView *container;
@property int numberOfSections;
@property CGAffineTransform startTransform;
@property (nonatomic, strong) NSMutableArray *sectors;
@property int currentSector;
@property (nonatomic, retain) UIImageView *mask;

- (id) initWithFrame:(CGRect)frame andDelegate:(id)del withSections:(int)sectionsNumber;
- (void)rotate;
- (void) buildSectorsEven;
- (void) buildSectorsOdd;

@end

在我的 .m 文件中

我的初始化方法

mask = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 58, 58)];
mask.image =[UIImage imageNamed:@"centerButton.png"];
mask.center = self.center;
mask.center = CGPointMake(mask.center.x, mask.center.y+3);
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonPressedDown:)];
[mask addGestureRecognizer:singleTap];
[mask setMultipleTouchEnabled:YES];
[mask setUserInteractionEnabled:YES];



-(IBAction)buttonPressedDown
{
    //Connect this IBAction to touchDown
    mask.alpha = 0.5f;
    NSLog(@"tapping the center of the earth");
}

当我点击图像时,它会因此消息而崩溃

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OOTRotaryWheel buttonPressedDown:]: unrecognized selector sent to instance 0x71724e0'
*** First throw call stack:

我以编程方式绘制了我的 UI,因此 Interface Builder 中没有 UI 元素。我的 UI 是一个故事板,但它是空的。

4

1 回答 1

2

您在 buttonPressedDown: 的实现中忘记了冒号。要么去掉 singleTap 定义的 action 参数中的冒号,要么将冒号和参数添加到你的实现中。

于 2012-10-02T18:50:14.130 回答