我找到了一些关于 PNS 的示例代码,文章在这里
我还创建了一个 UISwitch 来启用 PNS
如何给出控制 PNS 的方法?
这就是我声明单元格的方式
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]];
}
}
现在我只是使用单元格的文本标签颜色更改来表示开关调用方法
所以...我可以用它来控制 PNS 的启用与否???
感谢您的任何评论和回答!