私のプロジェクトはUIButtons
で、コードブロックを実行するのに1秒かかります。ALL UIButtonの遅延実行ブロック
私は他のプロジェクトのボタンが正常に動作していますが、何らかの理由でこのプロジェクトには迷惑をかけることがあります。
ボタンは、彼らはすぐに押される必要があるので、dailer番号です:1の 相続人例:ここでは
- (IBAction)phonePressed:(id)sender {
UITapGestureRecognizer *backspaceGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(backspace)];
UIButton *one = [[UIButton alloc] initWithFrame:CGRectMake(menuShadowLayer2.frame.origin.x+10, menuShadowLayer2.frame.origin.y+10, 80, 80)];
one.layer.cornerRadius = 40;
one.layer.borderColor = [UIColor lightGrayColor].CGColor;
one.layer.borderWidth = 1;
[one setBackgroundColor:[UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:0.3]];
[one setTitle:@"1" forState:UIControlStateNormal];
[one.titleLabel setTextAlignment:NSTextAlignmentCenter];
[one setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
[one.titleLabel setFont:[UIFont fontWithName:@"STHeitiSC-Light" size:50]];
[container addSubview:one];
[one addGestureRecognizer:tap1];
...
- (void)dailed1 {
numberDailed.text = [numberDailed.text stringByAppendingString:@"1"];
NSLog(@"1");
}
は遅くない場合は、同じように遅いですUIControlEventTouchUpInsideを使用して、別のボタンです。
UIButton *cancel = [[UIButton alloc] initWithFrame:CGRectMake(numberDailed.frame.origin.x, numberDailed.frame.origin.y+200, numberDailed.frame.size.width+40, 110)];
cancel.layer.cornerRadius = 15;
[cancel setImage:[UIImage imageNamed:@"cancel.png"] forState:UIControlStateNormal];
cancel.clipsToBounds = YES;
[container addSubview:cancel];
[cancel addTarget:self
action:@selector(clearNumber:)
forControlEvents:UIControlEventTouchDown];
...
-(IBAction)clearNumber:(id)sender{
[numberDailed setText:@""];
}
私はボタンUIControlEventTouchUpInside
またはTouchDown
さえも遅かったの使用などUITapGestureRecognizer
を使用していました。
このボタン(one
)を押すと、もう一度タップするまでに0.5秒ほど待たなければなりません。これは明らかに数字の半分と半分を入力することが文字列に追加されていないときに欲求不満を引き起こします。
UIScrollView
をdelaysContentTouches = NO;
に設定しました。ボタンがすぐにハイライト表示されます。すぐにコードを実行することはありません。 ボタンone
を例として使用しましたが、これは私のプロジェクトのALL UIButtons
に適用されます。 考えますか?あなたがジェスチャーを使用している
なぜ「UIButton」でタップジェスチャーを使用していますか? 'UIButton'はタップの処理をサポートしています。 – rmaddy
ボタンにタップジェスチャーが付いているのはなぜですか?既にタップジェスチャーがあるので、ボタンにはタップジェスチャーを追加しないでください。あなたはUIControlEventTouchUpInsideを使うべきです、なぜそれがより遅いのですか?詳細を追加してください。 –
@rmaddy私は通常、UIControlEventTouchUpInsideを使用しますが、投稿に記載されているように、私のタップジェスチャーよりもさらに遅いです。 – Manesh