I find some sample code about PNS,article here
and I also create an UISwitch to enable PNS
how to give a method to control the PNS ?
This is how I declare cell
cell.textLabel.text = @"PNS";
[cell.textLabel setTextColor:[UIColor grayColor]];
pushNotificationSwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
[cell addSubview:pushNotificationSwitch];
cell.accessoryView = pushNotificationSwitch;
[(UISwitch *)cell.accessoryView addTarget:self action:@selector(pushNotification:) forControlEvents:UIControlEventValueChanged];
}
- (void)pushNotification:(id)sender{
if (pushNotificationSwitch.on==YES) {
UITableViewCell *cell = (UITableViewCell*)pushNotificationSwitch.superview;
[cell.textLabel setTextColor:[UIColor blackColor]];
}
else {
UITableViewCell *cell = (UITableViewCell*)pushNotificationSwitch.superview;
[cell.textLabel setTextColor:[UIColor grayColor]];
}
}
now I'm just use a cell's text label color change to representation the switch is call the method
SO... can I use it to control PNS enable or not ???
Thanks for any comments and answers !