3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AutoLayoutの原因不明のバグ

Last updated at Posted at 2016-04-26

※iOS7の端末(iPhone5c)で発生。iOS8の端末(iPhone6 plus)では発生せず。

AutoLayoutでAspectRatioを使用した際に発生

詳細は不明だが、AspectRatioを使用した際に、iOS7の端末で強制終了してしまう場合がある模様。
内部的なレイアウト位置・サイズの計算で浮動小数誤差が累積することで発生する場合があると言われている。
(StackOverflow:http://stackoverflow.com/questions/17688370/autolayout-removefromsuperview-removeconstraints-throws-exception-and-crashes)

既に存在したQiitaの記事では、以下の方法が紹介されていた。
(Qiita:http://qiita.com/musclemikiya/items/0f550e35c1eafca2ebcf)

  • 16:9の比率を若干ずらして対応する
  • aspect ratioとheightを両方指定する

その他にも、

  • レイアウトエディタ上で定義順を変更
  • height・widthを割合で指定する(Propotional Height/Width)ような場合は、小数点以下の桁数は1桁/2桁程度に抑える。または、可能な限り「Reverse First And Second Item」を使用して関係を逆転し、設定値を整数にする

した場合にも症状が改善する場合があった。
今更な記事ではあるが、iOS7のサポートを継続する際に必要とすることがあるかもしれないので備忘録として残す。

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?