0

私の問題は、ラベルを含むカスタム セルがあることです。ラベルの値は、 TIME にある webServices を介して取得されます。最初に静的データを使用する場合、たとえば 10:54 PM の場合、そのセルをクリックすると、ラベルに設定された値のリマインダーが設定されます。もちろん、上記の時間に私に通知する必要があります。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    CC *cell=(CC*)[tableView cellForRowAtIndexPath:indexPath];

    NSDate *currentDate=[NSDate date];

    NSString *dateStr= cell.timeLabel.text;

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

    NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setLocale:[NSLocale currentLocale]];
    [dateFormatter setDateStyle:NSDateFormatterNoStyle];
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
    [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"];

    NSLog(@"date is %@",[dateFormatter dateFromString:datetoFire]);


    if (localNotification==nil) {
        return;
    }


    localNotification.fireDate=[dateFormatter dateFromString:datetoFire];
    localNotification.timeZone=[NSTimeZone defaultTimeZone];
    localNotification.alertBody=@"Good Morning dude..!";
    localNotification.repeatInterval=0; //The default value is 0, which means don't repeat.
    localNotification.soundName=UILocalNotificationDefaultSoundName;
    [[UIApplication sharedApplication]scheduleLocalNotification:localNotification];

}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CC *cell = (CC *) [tableView dequeueReusableCellWithIdentifier:@"CC"];
    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CC" owner:self options:nil];
        cell = (CC *) [nib objectAtIndex:0];
    }


    return cell;
}

私はこれをやってみましたが、これはうまくいきません。

ありがとうございました。

4

1 に答える 1

0

webservice から入力された値を含む動的配列を取得し、入力された時間を cell.In cellForRow メソッドでセルに動的に配置します。

以下のように静的配列を取得しました

time = [[NSMutableArray alloc] initWithObjects:@"5:35 PM",@"4:56 AM",@"6:00 PM",@"7:32 AM",nil];

Web サービスから入力されたデータを取得するため、この配列に値を動的に配置する必要があります。テーブルをリロードします。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CC *cell = (CC *) [tableView dequeueReusableCellWithIdentifier:@"CC"];
    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CC" owner:self options:nil];
        cell = (CC *) [nib objectAtIndex:0];
    }

    cell.textLabel.text=[time objectAtIndex:indexPath.row];

    return cell;
}

そして、selectメソッドでは、セルテキストラベルからではなく、配列から発火日を割り当てました

NSString *dateStr=[time objectAtIndex:indexPath.row];
于 2013-07-15T05:26:21.010 に答える