Domanda

I have been struggling for this issue for two week now. but by the help of StackOverflow people I have came up with 95% successful implementation..

Here is my problem.. and now I could load my results with the picker cell [First most cell] when the date is selected.

Now I have another issue...when i run my application at first time, it is works as I expected..but when i tap the first most cell to pick a different date , then the application crashed..

Here is the log output...

below is my codes for the implementation

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section             {

 NSDictionary* reqFdate= [ScheduleView getRequestForDate];

if (reqFdate.count == 0) {
    NSInteger numberOfRows = [self.persons count];

    if ([self datePickerIsShown]){

        numberOfRows++;

    }

    return numberOfRows;
}
else{

    return reqFdate.count + 1;
}

}




  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {


    UITableViewCell *cell;

    NSDate *today = [NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    // display in 12HR/24HR (i.e. 11:25PM or 23:25) format according to User Settings
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
    NSString *currentTime = [dateFormatter stringFromDate:today];
    NSDate *date=[dateFormatter dateFromString:currentTime];



    if(indexPath.row==0){
        VCPerson *person = self.persons[0];

        cell = [self createPersonCell:person];

    }



    else if ([self datePickerIsShown] && (self.datePickerIndexPath.row == 1)){

        // VCPerson *person = self.persons[indexPath.row -1];



        cell = [self createPickerCell:date];

    }

    else{

        cellForDatePickCell *cell = (cellForDatePickCell*)[self.tableView dequeueReusableCellWithIdentifier:kOtherCellIdentifier];
        cell.delegate_Dtepick = self;

        return cell;

    }


    if(indexPath.section!=0 && tapfirstCell) {

        UITableViewCell *cell = (UITableViewCell*)[self.tableView dequeueReusableCellWithIdentifier:kOtherCellIdentifier forIndexPath:indexPath];
        //cell.delegate_Dtepick = self;
        NSDictionary *dictionary = [_dataArray objectAtIndex:indexPath.section];
        NSArray *array = [dictionary objectForKey:@"data"];
        NSString *cellValue = [array objectAtIndex:indexPath.row];
        cell.textLabel.text =cellValue;

    }

    return cell;



}


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




[self.tableView beginUpdates];

if ([self datePickerIsShown] && (self.datePickerIndexPath.row - 1 == indexPath.row)){

    [self hideExistingPicker];
   // [self.tableView reloadData];
    //[self viewDidLoad];



    //call the service and take the results





    NSString* selecteDate = [ScheduleView getDate];

    NSString* prsonID =[LoginView getPersonID];

    NSDictionary* parms = [NSDictionary dictionaryWithObjectsAndKeys:prsonID,@"caregiverPersonId",selecteDate,@"selectedDate", nil];

    jsonpaser* jp = [[jsonpaser alloc]init];

    [jp getWebServiceResponce:@"http://qa.vardle.com/Mobile/WebServices/AppointmentService.asmx/GetAppointments" :parms success:^(NSDictionary *responseObject)
     {



         requestsF_date = responseObject;
         NSLog(@"RESPONSEFORDATE_IN DIDSELECT :%@",requestsF_date);
         NSArray* indexpaths = [self getIndexPaths];
         NSLog(@"indexPATHS %@",indexpaths);
         [self.tableView reloadData];

     }];






    // cellForDatePickCell *cell = (cellForDatePickCell*)[self.tableView dequeueReusableCellWithIdentifier:kOtherCellIdentifier forIndexPath:indexPath];
    // cell.delegate_Dtepick = self;
    //tapfirstCell = true;
   /*
   cellForDatePickCell *cell=(cellForDatePickCell*)[tableView cellForRowAtIndexPath:indexPath];
    if(![cell.textLabel.text isEqualToString:@"5/23/14"])
    {
        return; 
    }
  */


    if (tapfirstCell==false) {
        tapfirstCell = true;
    }
    else{
        tapfirstCell = false;
    }




}else {

    NSIndexPath *newPickerIndexPath = [self calculateIndexPathForNewPicker:indexPath];

    if ([self datePickerIsShown]){

        [self hideExistingPicker];



    }

    [self showNewPickerAtIndex:newPickerIndexPath];

    self.datePickerIndexPath = [NSIndexPath indexPathForRow:newPickerIndexPath.row + 1 inSection:0];

}

[self.tableView deselectRowAtIndexPath:indexPath animated:YES];

[self.tableView endUpdates];

}

please someone tell me where is the issue..why app is crashed when i try to pick a date second time..

please help

È stato utile?

Soluzione

i have fix my issue... i didnt deleted the rows before i start to show the date picker again..

here is the full code

here what i did was : i use Inline Datepicker with the table view [date picker will show by selecting the first cell of the table view].according to the date selected from the picker, i am displaying my custom cells below the first cell.[because the first cell always there to pick a date from a date picker].

if someone want to do the same thing which i did i think my code will help you

thank you

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top