UITableView强制sectionIndex更新而不调用reloadData

时间:2015-06-10 01:02:06

标签: ios objective-c uitableview photokit phphotolibrary

我正在从UITableView实例修改我的PHChange数据源,这样可以正常工作。我不明白的是,除非您使用UITableView重新加载整个UITableView,否则我无法更新reloadData右侧的sectionIndex。

还有其他方法可以强制更新UITableView右侧的sectionIndex吗?如果我手动拨打电话:sectionIndexTitlesForTableView:我确认我收到了新的数据,但是右边的旧部分索引并没有直观地改变,这就是我需要的。

代码:

PHFetchResultChangeDetails *changeDetails = [changeInstance changeDetailsForFetchResult:oldFetch];

if (changeDetails)
{
   PHFetchResult *fetchResultAfterChange = changeDetails.fetchResultAfterChanges;

   if (fetchResultAfterChange.count < 1)
   {
       [subArray removeObjectAtIndex:subIdx];

       dispatch_async(dispatch_get_main_queue(),^
       {
            NSIndexPath *path = [NSIndexPath indexPathForRow:subIdx inSection:idx];

            [self.albumsTableView deleteRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];

            // Confirmed data is updating            
            NSLog(@"%@",[self sectionIndexTitlesForTableView:self.albumsTableView]);

            // Does nothing                    
            [self.albumsTableView setNeedsDisplay];
        });
    }
}

1 个答案:

答案 0 :(得分:2)

尝试此功能

class Program { const string to = "number@vtext.com"; const string email = "myemail@gmail.com"; const string password = "password"; const string SMTPAddress = "smtp.gmail.com"; const int SMTPPort = 587; static void Main(string[] args) { Console.WriteLine("Type in the message"); string msgBody = Console.ReadLine(); Console.WriteLine("Sending Message..."); SendMsg(msgBody); Console.WriteLine("Click Enter to continue"); Console.Read(); } static MailMessage InitMailMessage(string msgBody) { MailMessage message = new MailMessage(); message.To.Add(new MailAddress(to)); message.From = new MailAddress(email, "The Displayed Name Not The Password"); message.Body = msgBody; return message; } static void SendMsg(string msgBody) { MailMessage msg = InitMailMessage(msgBody); SmtpClient smtp = new SmtpClient(); smtp.EnableSsl = true; smtp.Port = SMTPPort; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Credentials = new System.Net.NetworkCredential(email, password); smtp.Host = SMTPAddress; try { smtp.Send(msg); } catch (Exception ex) { ex.Dump(); Console.WriteLine(ex.Message); } } }

  

此方法为您提供了一种在插入或删除节之后更新节索引的方法,而无需重新加载整个表。