1
我有安排本地通知第一种方法:的iOS - 访问文本变量选择器查看到通知声音名称使用
- (void) scheduleLocalNotificationWithDate:(NSDate *)fireDate
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = fireDate;
notification.category = @"Alarm";
notification.soundName = @"Pager.caf";
[[UIApplication sharedApplication] scheduleLocalNotification: notification];
}
然后,我创建了一个选择器视图,用户可以选择在闹钟铃声名单用这种方法:
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
{
NSString *resultString = _alarmNames[row];
_alarmToneText.text = resultString;
}
现在,我想编辑的scheduleNotification方法来调用这是resultString选择器视图的文本值并把它放在notification.soundName。
下面是代码会是什么样子:
notification.soundName = resultString;
你的问题是什么? – user996142
我想使这个代码工作,notification.soundName = resultString;我需要从pickerView方法中获取变量resultString,并在我的notification.soundName中使用它 – theFool
您不能在调度通知文本后进行更改。你应该改变方法的签名为''' - (void)scheduleLocalNotificationWithDate:(NSDate *)fireDate andSound:(NSString *)sound'''并从''调用它 - (void)pickerView:(UIPickerView * )pickerView didSelectRow:(NSInteger)row'''。 – user996142