LoginSignup
1
1

More than 5 years have passed since last update.

scrollViewDidEndZooming:withView:atScale: の scale値

Posted at

UIScrollViewDelegateの関数で、ズームイン・アウト時に呼ばれるscrollViewDidEndZooming:withView:atScale:

この中の引数 atScale に入るスケール値が、iOS7.1.1 x iPhone5S の組み合わせの場合におかしいことになりました。

-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
    NSLog(@"scale = %f", scale);
}
結果

scale = 0.00000000021.....

のように極端に小さかったり、あるいは 0 になったり。

同じコードでも、
・iOS6.1 x iPhone5
・iOS7.1.1 x iPhone4
では、正常に値が取れていました。

調べても、同じ現象の記事は見つからなく、
ただ、警告として

Conflicting parameter types in implementation of 'scrollViewDidEndZooming:withView:atScale:': 'CGFloat' (aka 'double') vs 'float'

と出ていたので、型を float から CGFloat(or double) に変えたところ、上手く値が取れました。

ここ
http://stackoverflow.com/questions/23093752/conflicting-parameter-types-for-scroll-view-delegate
にあるように、64bitだとCGFloatにしないと上手く値が取れないのかもしれませんが、
一方でAppleのリファレンスの
https://developer.apple.com/library/ios/documentation/uikit/reference/uiscrollviewdelegate_protocol/reference/uiscrollviewdelegate.html#//apple_ref/occ/intfm/UIScrollViewDelegate/scrollViewDidEndZooming:withView:atScale:
には、型がfloatと載っているのでよくわからないままですが、とりあえずこれでいけそうです。

1
1
2

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