UIImageViewのUIButtonsを一括して使用しています。だから、私はこれらの2つを永久に結婚するカスタムクラスを作成して、少し簡単にしました。それは私が - (id)initWithObject:(AUIImageViewButton *)imageViewButtonを実装することを決定するまでうまく動作します。UIButtonターゲットイベント、アクションイベント、コントロールイベントを取得するには?
明らかに、渡されるimageViewButtonオブジェクトから関連するすべてのプロパティをコピーする必要があります。 UIImageViewはまったく問題ありません。このような何かがそれを扱う:
button = [UIButton buttonWithType:imageViewButton.button.buttonType]; // Copy all relevant data from the source's button
button.frame = imageViewButton.imageview.frame; //
[button setTitle:imageViewButton.button.titleLabel.text forState:UIControlStateNormal]; //
button.tag = imageViewButton.button.tag; //
私はaddTargetのすべてのデータを取得する方法を考え出す少し問題を抱えています:アクションボタンのもののほとんど
imageview = [[UIImageView alloc] initWithFrame:imageViewButton.imageview.frame]; // Copy all relevant data from the source's imageview
[imagebutton.imageview setBackgroundColor:imageViewButton.imageview.backgroundColor]; //
[imagebutton.imageview setImage:imageViewButton.imageview.image]; //
も容易に利用可能です:forControlEventsメソッド。
ドキュメントを見ると、UIControlのallControlEventsメソッドとallTargetsメソッドを使用できることがわかります。私は今それを掘り下げ、私がどれくらいの苦労を受けるのかを見ていきます。私が確信しているのはその行動です。
誰も私に正しい方向に押しつけることができますか?
おかげで、
-Martin
をちょうどチェックし、あなたはUIButtonが背景画像(タイトルテキストが上に表示される)と画像(タイトルテキストが表示されない)の両方をサポートすることを知っていますか? UIImageViewのどの機能が必要ですか? – Bogatyr