Xcode 開発で文字の点滅がスルーされている。

Xcode 7で作成したiOSアプリで、 Xcode 8から文字の点滅が怪しい動き(反応しない)になりました。iOS側の問題の可能性もあるので、未対応のままで Xcode 9で再チェックすると全くスルーされる現象になっていました。

以下の実装は、完全スルー状態です。 Xcode 7時点では、動作していました。どこに原因があるのか不明ですが、 Xcode 環境最新化による突然の仕様変更になると思われます。

1       //点滅
2       [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations:^{
3            
4           [UIView setAnimationRepeatCount:20.0];
5           self.XXXXX.alpha = 0.0;
6       }
7                        completion:^(BOOL finished){
8                            self.XXXXX.alpha = 1.0;}];
9   }
10}

Objective-cで点滅に関して情報収集ができないので、この方法はあきらめて代替方法で対処しました。


代替方法

アニメーション機能を使用して点滅処理を代替しています。文字を消す・表示を繰り返すロジックで20回目で終了する実装になっています。

1//グローバル変数として宣言
2NSInteger Wcnt_dsp;     //点滅カウント
3 
4 
5//点滅させたい箇所
6 
7           Wcnt_dsp = 0;//点滅カウント
8           [self performSelector:@selector(showTime_01) withObject:nil afterDelay:0.8];
9 
10/* サブロジック */
11 
12-(void)showTime_01{//点滅 消す
13     
14    UILabel *aLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 50)];
15     
16    self.XXXXX.alpha = 0.0;
17     
18    [self.view addSubview:aLabel];
19     
20    [self performSelector:@selector(showTime_02) withObject:nil afterDelay:1.0];
21    
22}
23-(void)showTime_02{//点滅 表示
24     
25    UILabel *aLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 50)];
26     
27    self.XXXXX.alpha = 1.0;
28    Wcnt_dsp++;//点滅カウント
29     
30    [self.view addSubview:aLabel];
31     
32    if (Wcnt_dsp < 20){
33        [self performSelector:@selector(showTime_01) withObject:nil afterDelay:1.0];
34    }
35}
Verified by MonsterInsights