Xcode 7で作成したiOSアプリで、 Xcode 8から文字の点滅が怪しい動き(反応しない)になりました。iOS側の問題の可能性もあるので、未対応のままで Xcode 9で再チェックすると全くスルーされる現象になっていました。
以下の実装は、完全スルー状態です。 Xcode 7時点では、動作していました。どこに原因があるのか不明ですが、 Xcode 環境最新化による突然の仕様変更になると思われます。
//点滅
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations:^{
[UIView setAnimationRepeatCount:20.0];
self.XXXXX.alpha = 0.0;
}
completion:^(BOOL finished){
self.XXXXX.alpha = 1.0;}];
}
}
Objective-cで点滅に関して情報収集ができないので、この方法はあきらめて代替方法で対処しました。
代替方法
アニメーション機能を使用して点滅処理を代替しています。文字を消す・表示を繰り返すロジックで20回目で終了する実装になっています。
//グローバル変数として宣言
NSInteger Wcnt_dsp; //点滅カウント
//点滅させたい箇所
Wcnt_dsp = 0;//点滅カウント
[self performSelector:@selector(showTime_01) withObject:nil afterDelay:0.8];
/* サブロジック */
-(void)showTime_01{//点滅 消す
UILabel *aLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 50)];
self.XXXXX.alpha = 0.0;
[self.view addSubview:aLabel];
[self performSelector:@selector(showTime_02) withObject:nil afterDelay:1.0];
}
-(void)showTime_02{//点滅 表示
UILabel *aLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 50)];
self.XXXXX.alpha = 1.0;
Wcnt_dsp++;//点滅カウント
[self.view addSubview:aLabel];
if (Wcnt_dsp < 20){
[self performSelector:@selector(showTime_01) withObject:nil afterDelay:1.0];
}
}
