私のプロジェクトでは、目的のために以下のコードを使用しましたが、正しく機能しています。私のコード:
UIView *view = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",index]]] autorelease];
view.frame = CGRectMake(70, 80, 180, 260);
return view;
しかし、ここでは UIImageView の代わりに UIButton を使用したいので、上記のコードの最初の行を次のように置き換えました。
UIView *view=[[UIButton alloc] setBackgroundImage:(UIImage *)[scrollImages objectAtIndex:index] forState:UIControlStateNormal];
しかし、この時点でエラーメッセージが表示されます
「互換性のない型 'void' の式で 'UIView*_strong' を初期化しています」.
UIImageViewをUIButtonに置き換えることで、これを解決するのを手伝ってくれる人はいますか....