我有一個很大的問題。我已經分類MKAnnotationView
並添加了三個UIImageViews
每個與圖像。註釋在地圖上看起來很好。但是,它們不捕獲觸摸事件。我已經嘗試了self.userInteractionEnabled
和exclusiveTouch
,但似乎沒有任何工作。註解視圖中的子視圖不檢測觸摸事件
(ID)initWithAnnotation:(ID)註釋reuseIdentifier:(的NSString *)reuseIdentifier {
self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]; self.frame = CGRectMake(0, 0, kWidth, kHeight); UIImage *image = [UIImage imageNamed:@"geo-icon.png"]; UIImageView * turbineView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ]; UIImageView * mastroView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(20.0, 100.0, image.size.width, image.size.height) ]; mastroView.image = image; mastroView.userInteractionEnabled = NO; mastroView.exclusiveTouch = NO; [turbineView addSubview:mastroView]; image = [UIImage imageNamed:@"turbine-noshadow.png"]; propellerView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(4.0, 82.0, image.size.width, image.size.height) ]; propellerView.image = image; propellerView.userInteractionEnabled = NO; propellerView.exclusiveTouch = NO; [turbineView addSubview:propellerView]; image = [UIImage imageNamed:@"arrow.png"]; UIImageView * arrowView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(32.0, 114.0, image.size.width, image.size.height) ]; arrowView.image = image; arrowView.userInteractionEnabled = NO; arrowView.exclusiveTouch = NO; [turbineView addSubview:arrowView]; image = [UIImage imageNamed:@"run-turbine.png"]; UIImageView * stoprunView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(65.0, 155.0, image.size.width, image.size.height) ]; stoprunView.image = image; stoprunView.userInteractionEnabled = NO; stoprunView.exclusiveTouch = NO; [turbineView addSubview:stoprunView]; turbineView.userInteractionEnabled = NO; turbineView.exclusiveTouch = NO; [self addSubview:turbineView]; self.userInteractionEnabled = NO; self.exclusiveTouch = NO; self.opaque = NO; [self rodar]; // return self;
}
請張貼包含上下文視圖的代碼 – Dreen
註解代表螺旋槳旋轉通過動畫的eolic渦輪機。每個UIImageView都有一部分渦輪機的圖像。帶螺旋槳圖像的UIImageView旋轉。這裏是代碼: – lnj
有關於此的任何更新?我有同樣的問題。 – digidigo