2012-10-02 93 views
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文件的UIImageView崩潰增加UITapGestureRecognizer

我的init方法

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元素。我的UI是一個故事板,但它是空的。

回答

2

您在執行buttonPressedDown時忘記了冒號:.要麼擺脫您的singleTap定義的動作參數中的冒號,要麼將冒號和參數添加到您的實現中。

+0

我該如何註冊touchUpEvent?當UIImage不再被觸摸時,我想改變alpha。 –

+0

這就是singleTap所做的 - 「輕擊」是一個觸摸,然後觸摸一下,所以只有觸摸起來,才能調用buttonPressedDown。 – rdelmar

相關問題