私はカスタムビューインターフェイスを含む物語を持っています。ここにはcustomeviewクラスの定義があります。UISwitchボタンをクリックする方法
@interface CustomTableCellview : UITableViewCell {
UILabel *titleOfPost;
UILabel *userProfileName;
UIImageView* profileImage;
UILabel *countOfFave;
}
@property(nonatomic,retain) IBOutlet UIImageView *profileImage;
@property(nonatomic,retain) IBOutlet UILabel *titleOfPost;
@property(nonatomic,retain) IBOutlet UILabel *countOfFave;
@property(nonatomic,retain) IBOutlet UILabel *userProfileName;
これらの値はすべて私のテーブルに表示されています。ユーザーがON/OFFボタンのいずれかをクリックするたびに関数を呼び出す必要があります。ここに私のtableviewクラス定義があります。
@interface VIPsScreen : UITableViewController {
NSMutableArray* tableList;
IBOutlet CustomVIPCell *tblCell;
NSMutableArray* chengdArray;
}
UISWitchの値が "ON"の配列 "chengdArray"にすべての関連する "userProfileName"を保存します。どのようにしてこの問題を解決しますか?事前に おかげ
はい私は今関数呼び出しを取得しています。しかし、それがどの行でクリックされたかをどのように知るでしょう。私はこのように付け加えました。 cell.userName.text = [プロファイルユーザー名objectAtIndex:indexPath.row]; cell.userProfileImage.image = [UIImage imageNamed:[imageData objectAtIndex:indexPath.row]]; [cell.VIPsYEsNo addTarget:セルフアクション:@セレクタ(アクション:) forControlEvents:UIControlEventValueChanged];関数「アクション」でパラメータを渡すことはできますか? – user851954
最も簡単な方法は、VIPsYEsNoのタグプロパティを使用することです。行インデックスまたはデータセットに関連するその他のインデックスに設定できるとします。 ' - (void)action:(id)sender;'送信者は実際にトリガされたUISwitchであるので、タグ値を返すことができます。 – Ariel
これはすばらしいです:)。 UISwitchボタンがオンかオフかを知る方法を教えてください。 – user851954