私はそれを押すと、私が追加したターゲットセレクターを起動しないボタンがあります。私はボタンの異なるイメージを作ったので、私はそれを押すことがわかります。外部にドラッグしない限り、UIButtonはtouchUpInside上のターゲットを発射しませんか?
私はここをクリックし、ボタンの外側にドラッグしますが、ボタンのすぐ上のスーパービューの外にはドラッグしないでください。ターゲットセレクタが起動されます。
私はまた、すべてのスーパー/サブビューでsetClipsToBounds:YESを設定して、それがビューの境界内にあることを確認しました。境界内にあるようだ。ボタン領域の外にドラッグすると無指向であるように見えるので、右にタップ/ドラッグするだけのことはできません。左と右の仕事も残してください。私はタップすることができます、それからドラッグして戻って、それは動作します。ドラッグを開始せずにタップしたままにすると、ボタンがハイライト表示されてから非選択状態に戻ります。
ボタンのコードは次のとおりです。ボタンはUITextView、実際にはUITextViewのonTopと共にUIViewにあります。スケーリング/スクロールビューに
messageLookupButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 21, 20)];
[messageLookupButton setTitle:@"junk" forState:UIControlStateNormal];
[messageLookupButton sizeToFit];
[messageLookupButton setTag:kGearButtonView];
//Get the images for the buttons
UIImage *gearButtonImage = [UIImage imageNamed:@"gear.png"];
UIImage *gearButtonImage2 = [UIImage imageNamed:@"StatusLightOn.png"];
[messageLookupButton setImage:gearButtonImage forState:UIControlStateNormal];
[messageLookupButton setImage:gearButtonImage2 forState:UIControlStateHighlighted];
[messageLookupButton addTarget:self action:@selector(gearPressed:) forControlEvents:UIControlEventTouchUpInside];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(processLookupResults:)
name:kRefreshFromPopover object:nil];
[self addSubview: messageLookupButton ];
[messageLookupButton release];
[messageLookupButton setCenter:CGPointMake(CGRectGetMaxX(elementViewContents.bounds) -kElementContentFrameOffset -(CGRectGetWidth(messageLookupButton.bounds)/2), CGRectGetMidY(elementViewContents.bounds))];
[self bringSubviewToFront:messageLookupButton];
あるこのすべてであるが、拡大表示であることをUIViewのは、スクロールビューは、その上にいくつかのジェスチャー認識機能を持っています。彼らは私がスクリーンに置いた他のボタンやコントロールを妨害しているようには見えませんが。私はそのスクロールビューが問題であると感じていますが。
スクロールビューのコードクリップ:
[scrollContentView setUserInteractionEnabled:YES];
[scrollContentView setExclusiveTouch:YES];
[scrollContentView setCanCancelContentTouches:YES];
[scrollContentView setDelaysContentTouches:YES];