LoginSignup
13
13

More than 5 years have passed since last update.

一行で出来る!!「objective-c【iOS】」タッチイベントの無効化・有効化

Last updated at Posted at 2014-08-16

はじめに

非同期通信等を行う際に画像が表示されるまで、タッチを無効にしたい...!
そんな時、たった一行でタッチイベントを無効化・有効化することが出来ます!!

タッチイベント無効化

無効化
//ボタンのセット
self.btImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)] autorelease];

//ボタンの無効化
self.btImageView.userInteractionEnabled = NO;

タッチイベント有効化

有効化
//ボタンのセット
self.btImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)] autorelease];

//ボタンの有効化
self.btImageView.userInteractionEnabled = YES;

これだけです。
有効化・無効化したいタッチイベントに対して
self.btImageView.userInteractionEnabled = NO //無効化
self.btImageView.userInteractionEnabled = YES //有効化

是非試してみてください。

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13