iphone - 如何知道点击了 UISwitch 按钮

标签 iphone uiswitch

我有一个故事,其中包含自定义 View 界面。这是customeview类定义。

@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;

这些所有值都显示在我的表格中。每当用户单击开/关按钮时,我想调用一个函数。这是我的 TableView 类定义。

 @interface VIPsScreen : UITableViewController {
 NSMutableArray* tableList;

IBOutlet CustomVIPCell *tblCell;

NSMutableArray* chengdArray;

}

我想将所有相关的“userProfileName”存储在数组“hengdArray”中,该数组的 UISWitch 值为“ON”。我将如何解决这个问题。 提前致谢

最佳答案

使用

[switchCtl addTarget:self action:@selector(action:) forControlEvents:UIControlEventValueChanged];

初始化 UISwitch 实例的位置

-(void)action:(id)sender{

}

作为一种回调方法,您应该在其中检查是否已切换并采取操作...

关于iphone - 如何知道点击了 UISwitch 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6749941/

相关文章:

iphone - 基于Apple的 'glPaint'的OpenGL绘画程序在白色背景上 - 如何混合?

ios - 是否有用于平移或缩放 map 的 Google map 事件监听器?

iOS:为 UISwitch 设置默认值

ios - 切换 UI 元素图形问题

ios - 可重复使用的 tableview 单元格相互影响而无需交互

iphone - 没有 xCode 的 Phonegap WEB-APP

iphone - 未调用 UIViewController 准备 segue 方法

iOS URL 方案问题

ios - UITableView 中的 UISwitch 在滚动时重置为原始值

ios - 设置 UI 元素的默认颜色