PNSに関するサンプルコードをいくつか見つけました。記事はこちら
また、PNSを有効にするUISwitchを作成します
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を有効にするかどうかを制御するためにそれを使用できますか?
コメントと回答をありがとう!