我有一个包含自定义视图界面的故事。这是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