Ios 基于标签的文本/值调用UILocalNotification

Ios 基于标签的文本/值调用UILocalNotification,ios,uilocalnotification,custom-cell,Ios,Uilocalnotification,Custom Cell,我的问题是: 我有一个TableVC,其中有自定义单元格。 这些自定义单元格有各种标签,其中之一是时间标签。 timeLabel的文本将通过解析xml获取。 但现在假设我使用静态内容,例如:下午2:45。 我是否可以将此文本作为UILocalNotification的fireDate提供,当然它应该在上述时间触发。 应在单击“DidSelectRowatineXpath”中的单元格时执行此操作。 或者这是不可能做到的 是的,如果这是一个重复的问题,你不喜欢它,或者如果有一些拼写错误或任何相关的问

我的问题是: 我有一个TableVC,其中有自定义单元格。 这些自定义单元格有各种标签,其中之一是时间标签。 timeLabel的文本将通过解析xml获取。 但现在假设我使用静态内容,例如:下午2:45。 我是否可以将此文本作为UILocalNotification的fireDate提供,当然它应该在上述时间触发。 应在单击“DidSelectRowatineXpath”中的单元格时执行此操作。 或者这是不可能做到的

是的,如果这是一个重复的问题,你不喜欢它,或者如果有一些拼写错误或任何相关的问题,请不要在它上标记为否决票。 我过去见过人们玩这种廉价的把戏,以不健康和不专业的方式利用他们所谓的声誉

我们热烈欢迎您的相关答复

谢谢你

编辑 我试过这个东西

 NSString *str = cell.timeLabel.text;
    NSLog(@"str = %@",str);
    formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"MM/dd/yyyy hh:mm a"];
    NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
    [formatter setTimeZone:gmt];
    date = [formatter dateFromString:str];
在cellForRowAtIndexPath中显示上述内容


这可能会对u@Herçules有所帮助:谢谢你的回答,但兄弟,我不想重复。当用户单击单元格时,它会弹出一个弹出窗口,你确定要添加提醒吗?如果用户单击“是”,它会根据单元格中标签的值设置点火日期。你只想触发一次警报,对吗?是的。标签上指定的时间(即其文本)通过webService。现在我们可以使用静态文本,如3:21pm,这可能会对你有所帮助。Herçules:谢谢你的回答,但兄弟,我不想重复。当用户单击单元格时,它会弹出一个弹出窗口,你确定要添加提醒吗?如果用户单击“是”,它应该根据给的值设置fireDate单元格中的标签。只有一次您想要火警,对吗?是的。标签上指定的时间(即其文本)通过webService传输。现在我们可以使用静态文本,如下午3:21
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{



    UILocalNotification *localNotif = [[UILocalNotification alloc] init];

    localNotif.fireDate = [NSDate dateWithTimeInterval:5 sinceDate:date];

    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    localNotif.alertBody = @"You are notified";
    localNotif.soundName = UILocalNotificationDefaultSoundName;
    [[UIApplication sharedApplication]scheduleLocalNotification:localNotif];

}
NSDate *currentDate=[NSDate date];
NSString *dateStr=@"7:10 PM";
UILocalNotification *localNotification =[[UILocalNotification alloc]init];
NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"hh:mm a"];
[dateFormatter setTimeZone:gmt];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];

NSString *preFix=[dateFormatter stringFromDate:currentDate];
NSString *datetoFire=[NSString stringWithFormat:@"%@ %@",preFix,dateStr];

[dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm a"];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm a"];

NSDate *fireDate = [dateFormatter dateFromString:datetoFire];
fireDate=[fireDate dateByAddingTimeInterval:-(60*60*(5.5))];

NSLog(@"date is %@",fireDate);

// Cancel the previously scheduled notification, if any.
if (localNotification == nil) {
    return;
}

localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody = @"Good Morning Buddies";
localNotification.alertAction = @"View";
localNotification.fireDate = fireDate;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber++;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];