Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 通过web服务插入数据后在TableView中重新加载数据_Objective C_Ios7 - Fatal编程技术网

Objective c 通过web服务插入数据后在TableView中重新加载数据

Objective c 通过web服务插入数据后在TableView中重新加载数据,objective-c,ios7,Objective C,Ios7,我正在使用JSON解析在UITableView中上载数据。一切正常,但在通过textView插入数据后,它将上载到服务器上,但在我以前和当前的UITableView中它不会刷新。我需要重新启动我的项目以查看上载的数据。插入数据后,我想重新加载我的UITableView。我使用了[self.myTableView reloadData],但它在任何地方都不起作用 -(PrayerListCustomCell *)tableView:(UITableView *)tableView cellForR

我正在使用JSON解析在
UITableView
中上载数据。一切正常,但在通过textView插入数据后,它将上载到服务器上,但在我以前和当前的
UITableView
中它不会刷新。我需要重新启动我的项目以查看上载的数据。插入数据后,我想重新加载我的
UITableView
。我使用了
[self.myTableView reloadData]
,但它在任何地方都不起作用

-(PrayerListCustomCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: 
  (NSIndexPath *)indexPath
 {
   static NSString *CellIdentifier = @"Cell";
    PrayerListCustomCell *cell = (PrayerListCustomCell *)[tableView 
           dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
         cell = [[[NSBundle mainBundle]loadNibNamed:@"PrayerListCustomCell" 
        owner:self options:nil]objectAtIndex:0];
 }

  cell.dateLbl.text = [dateList objectAtIndex:indexPath.row];
  cell.prayerLbl.text = [prayerList objectAtIndex:indexPath.row];
  return cell;
}
 -(void)submitClicked
{
if ([prayerTextView.text isEqualToString:@""]) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Please fill 
     your request in text box!" delegate:self cancelButtonTitle:@"OK"  
     otherButtonTitles:nil, nil];
    [alert show];
}
else
{
    prayerSubmitData = prayerTextView.text;
    SubmitPrayer *submit = [[SubmitPrayer alloc]init];
    [ASKevrOperationManager submitPrayer:submit handler:^(id object , NSError *error 
       , BOOL success)
     {
         if (success) {
             NSLog(@"this is request data = %@",object);
             UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil 
              message:@"Successful upload!" delegate:nil cancelButtonTitle:@"OK" 
              otherButtonTitles:nil];
             [alert show];
             prayerTextView.text = @"";
             [self.requestTableView reloadData];
            //Do refreshment code
         }
         else
         {
             UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil 
            message:@"Please try again later!" delegate:nil cancelButtonTitle:@"OK" 
             otherButtonTitles:nil];
             [alert show];
         }
     } ];
    }
  }

您需要将提交的数据添加到
rajerlist
数组中。这应该是这样的:

if (success) {
   // show alert

   [prayerList addObject:prayerTextView.text];
   [self.requestTableView reloadData];
   prayerTextView.text = @"";

   //Do refreshment code
}

您是否也在更新您的模型?如果我们可以看到一些代码,这会有所帮助您是否尝试在
重新加载数据后
setNeedDisplay
?您是否可以在此处添加代码示例以查找您的问题。..Hey@Chaaruu在重新加载数组后重新加载json和表。,我尝试了这个,但它崩溃了,因为我正在从服务器调用数据,该服务器正在进行日期和时间祈祷。如果我跟随您,我只有一个解决方案。解决方案是我需要用数据传递日期和时间,然后只有我可以更新日期和时间,否则我需要再次调用此web服务来刷新表数据。您还有其他解决方案吗?为什么您不也将日期对象添加到
日期列表
数组中吗?编辑:啊,我看到你只从web服务获取日期,而没有本地的日期。因此,您需要再次从服务器检索数据,然后重新加载tableView,或者需要在本地生成日期并将其添加到日期列表数组中。