user851954
user851954

Reputation: 25

How to know UISwitch button clicked

I have a tale which is containing a custom view interface. Here is customeview class definition.

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

These all values are showing in my table. I want to call a function whenever user will click either ON/OFF button. Here is my tableview class definition.

 @interface VIPsScreen : UITableViewController {
 NSMutableArray* tableList;

IBOutlet CustomVIPCell *tblCell;

NSMutableArray* chengdArray;

}

I want to store all related "userProfileName" in array "chengdArray" which has UISWitch values "ON". How will I resolve this problem. Thanks in advance

Upvotes: 2

Views: 3486

Answers (2)

Rahul Joshi
Rahul Joshi

Reputation: 1

You can use this [tempSwitch isOn] with an if statement where tempSwitch is the name of your switchView

Upvotes: 0

Ariel
Ariel

Reputation: 2440

Use

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

where you're initializing instances of UISwitch and

-(void)action:(id)sender{

}

as a callback method where you should check with one was switched and take actions...

Upvotes: 8

Related Questions