この問題の解決策を見つけました。そうではないことは承知していますが、iOS 8 が市場に投入されるまでは確実に機能します。
クラッシュの理由:
iOS 7では、代わりにand is not the property を[self.subViews objectAtIndex: i]
返し、アプリがクラッシュします。この次のコードを使用して問題を解決します。UIView
UIImageView
setImage
UIView
サブビューがUIView
(iOS7 の場合) またはUIImageView
(iOS6 以前の場合) であるかどうかを確認します。もしそうなら、UIView
私はUIImageView
そのビューにサブビューとして追加し、出来上がりは機能し、クラッシュしません..!!
-(void) updateDots
{
for (int i = 0; i < [self.subviews count]; i++)
{
UIImageView * dot = [self imageViewForSubview: [self.subviews objectAtIndex: i]];
if (i == self.currentPage) dot.image = activeImage;
else dot.image = inactiveImage;
}
}
- (UIImageView *) imageViewForSubview: (UIView *) view
{
UIImageView * dot = nil;
if ([view isKindOfClass: [UIView class]])
{
for (UIView* subview in view.subviews)
{
if ([subview isKindOfClass:[UIImageView class]])
{
dot = (UIImageView *)subview;
break;
}
}
if (dot == nil)
{
dot = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, view.frame.size.width, view.frame.size.height)];
[view addSubview:dot];
}
}
else
{
dot = (UIImageView *) view;
}
return dot;
}
これでiOS7の問題も解決されることを願っています。誰かがそのための最適な解決策を見つけたら、コメントしてください. :)
ハッピーコーディング