我有一個包含自定義視圖界面的故事。這是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;
}
我想將所有相關的「userProfileName」存儲在UISWitch值爲「ON」的數組「chengdArray」中。我將如何解決這個問題。 在此先感謝
是的,我現在正在調用函數。但是,我怎麼知道點擊哪一行。我像這樣添加它。 cell.userName.text = [profileUserName objectAtIndex:indexPath.row]; cell.userProfileImage.image = [UIImage imageNamed:[imageData objectAtIndex:indexPath.row]]; [cell.VIPsYEsNo addTarget:self action:@selector(action :) forControlEvents:UIControlEventValueChanged];我可以在函數「action」中傳遞參數嗎? – user851954
最簡單的方法是使用VIPsYEsNo的標籤屬性。假設您可以將其設置爲行索引或與您的數據集相關的任何其他索引。在' - (void)action:(id)sender;'發件人實際上是一個被觸發的UISwitch,所以你可以從中取回標籤值。 – Ariel
它工作很棒:)。請幫助如何知道UISwitch按鈕是ON還是OFF檢測。 – user851954