UITableView 部分未按预期排序

2024-03-20

我正在使用带有自定义部分标题的 tableView。核心数据对象根据称为“sectionIdentifier”的瞬态属性的值显示在精确的部分上。一切都按预期工作,但各部分的顺序没有按我的预期响应。这应该是部分顺序:

1. OVERDUE, sectionIdentifier = 0
2. TODAY, sectionIdentifier = 1
3. TOMORROW, sectionIdentifier = 2
4. UPCOMING, sectionIdentifier = 3
5. SOMEDAY, sectionIdentifier = 4

At this app state, the section order is as shown in the image below: enter image description here

欢迎任何帮助来解释此行为并找到获得所需部分顺序的方法。 这是我的代码,可以帮助您找到问题。

#import "ToDoItemsTableViewController.h"
#import "AppDelegate.h"
#import "AddToDoItemViewController.h"
#import "ToDoSubItemsTableViewController.h"

@interface ToDoItemsTableViewController ()<UIAlertViewDelegate>

@property (nonatomic, strong)NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong)NSFetchedResultsController *fetchedResultsController;

@end

@implementation ToDoItemsTableViewController
@synthesize searchResults;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(NSManagedObjectContext *)managedObjectContext{
    return [(AppDelegate*)[[UIApplication sharedApplication]delegate]managedObjectContext];
}
- (void)viewDidLoad
{
    [super viewDidLoad];


    //navigation bar background image
    [self.navigationController.navigationBar

     setBackgroundImage:[UIImage imageNamed:@"navBar.png"]

     forBarMetrics:UIBarMetricsDefault];

    NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [UIColor whiteColor],NSForegroundColorAttributeName,
                                    [UIColor whiteColor],NSBackgroundColorAttributeName,nil];
    self.navigationController.navigationBar.titleTextAttributes = textAttributes;
    self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navBar"]];


    NSError *error = nil;
    if (![[self fetchedResultsController]performFetch:&error]){
        NSLog(@"Error %@",error);
        abort();
    }
    self.searchResults = [NSMutableArray arrayWithCapacity:[[self.fetchedResultsController fetchedObjects] count]];
    [self.tableView reloadData];
}
-(void) viewWillAppear:(BOOL)animated{
    [self.tableView reloadData];
}
- (void)viewDidUnload
{
    self.searchResults = nil;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

    if ([[segue identifier]isEqualToString:@"addToDoItem"]){
        UINavigationController *navigationController = segue.destinationViewController;

        AddToDoItemViewController *addToDoItemViewController = (AddToDoItemViewController*)navigationController.topViewController;
        ToDoItem *addToDoItem = [NSEntityDescription insertNewObjectForEntityForName:@"ToDoItem" inManagedObjectContext:self.managedObjectContext];
        addToDoItem.todoDueDate = [NSDate date];
        addToDoItemViewController.addToDoItem = addToDoItem;
    }
    if ([[segue identifier] isEqualToString:@"toToDoSubItems"]){

        ToDoSubItemsTableViewController *todoSubItemsTableViewController = [segue destinationViewController];
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        ToDoItem *selectedToDoItem = (ToDoItem*)[self.fetchedResultsController objectAtIndexPath:indexPath];
        todoSubItemsTableViewController.selectedToDoItem = selectedToDoItem;



    }




}



#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        return 1;
    }
    else
    {
        return [[self.fetchedResultsController sections]count];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        return [self.searchResults count];
    }
    else {
    id<NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections]objectAtIndex:section];
    return [sectionInfo numberOfObjects];

    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    // Configure the cell...

    ToDoItem *toDoItem = nil;



    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        if (cell==nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
            cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

        }
        NSLog(@"Configuring cell to show search results");
        toDoItem = [self.searchResults objectAtIndex:indexPath.row];
        cell.textLabel.text = toDoItem.todoName;



        NSDate *fechaToDO = toDoItem.todoDueDate;

        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
        [dateFormatter setDateFormat:@"EEEE, dd MMMM YYYY"];
        NSString *fechaToDo = [dateFormatter stringFromDate:fechaToDO];



        cell.detailTextLabel.text = fechaToDo;

    }
    else
    {


    ToDoItem *todoItem = [self.fetchedResultsController objectAtIndexPath:indexPath];
    cell.textLabel.text = todoItem.todoName;



    NSDate *fechaToDO = todoItem.todoDueDate;

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"EEEE, dd MMMM YYYY"];
    NSString *fechaToDo = [dateFormatter stringFromDate:fechaToDO];



    cell.detailTextLabel.text = fechaToDo;
    }
    return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    static NSString *header = @"customHeader";

    UITableViewHeaderFooterView *vHeader;

    vHeader = [tableView dequeueReusableHeaderFooterViewWithIdentifier:header];

    if (!vHeader) {
        vHeader = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:header];
        vHeader.textLabel.backgroundColor = [UIColor redColor];
        vHeader.textLabel.textColor = [UIColor whiteColor];

        vHeader.contentView.backgroundColor = [UIColor redColor];
    }

    if (section == 0) {
        vHeader.textLabel.backgroundColor = [UIColor redColor];
        vHeader.textLabel.textColor = [UIColor whiteColor];


        vHeader.contentView.backgroundColor = [UIColor redColor];
    }

    else if (section == 1) {
        vHeader.textLabel.backgroundColor = [UIColor orangeColor];
        vHeader.textLabel.textColor = [UIColor blueColor];

        vHeader.contentView.backgroundColor = [UIColor orangeColor];
    }
    else if (section == 2) {
        vHeader.textLabel.backgroundColor = [UIColor greenColor];
        vHeader.textLabel.textColor = [UIColor whiteColor];

        vHeader.contentView.backgroundColor = [UIColor greenColor];
    }
    else if (section == 3) {
        vHeader.textLabel.backgroundColor = [UIColor greenColor];
        vHeader.textLabel.textColor = [UIColor whiteColor];

        vHeader.contentView.backgroundColor = [UIColor greenColor];
    }
    else if (section == 4) {
        vHeader.textLabel.backgroundColor = [UIColor blueColor];
        vHeader.textLabel.textColor = [UIColor whiteColor];

        vHeader.contentView.backgroundColor = [UIColor blueColor];
    }


    vHeader.textLabel.text = [self tableView:tableView titleForHeaderInSection:section];

    return vHeader;
}
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{

    if (tableView == self.searchDisplayController.searchResultsTableView){
        NSString *valor = [NSString stringWithFormat:@"S E A R C H   R E S U L T S (%d)",[self.searchResults count]];
        return valor;
    }
    else {


    id <NSFetchedResultsSectionInfo> theSection = [[self.fetchedResultsController sections]objectAtIndex:section];
    NSString *sectionname = [theSection name];

    if ([sectionname isEqualToString:@"0"]){

        NSString *valor = [NSString stringWithFormat:@"O V E R D U E   (%d)", [self.tableView
                                                             numberOfRowsInSection:section]];
        return valor;
    }
    else if ([sectionname isEqualToString:@"1"]){

        NSString *valor = [NSString stringWithFormat:@"T O D A Y   (%d)", [self.tableView
                                           numberOfRowsInSection:section]];
        return valor;
    }
    else if ([sectionname isEqualToString:@"2"]){

        NSString *valor = [NSString stringWithFormat:@"T O M O R R O W   (%d)", [self.tableView
                                                             numberOfRowsInSection:section]];
        return valor;
    }
    else if ([sectionname isEqualToString:@"3"]){

        NSString *valor = [NSString stringWithFormat:@"U P C O M I N G   (%d)", [self.tableView
                                                                                 numberOfRowsInSection:section]];
        return valor;
    }

    else if ([sectionname isEqualToString:@"4"]){

        NSString *valor = [NSString stringWithFormat:@"S O M E D A Y    (%d)", [self.tableView
                                                                                 numberOfRowsInSection:section]];
        return valor;
    }


    if ([[self.fetchedResultsController sections]count]>0){
        id<NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections]objectAtIndex:section];
        return [sectionInfo name];
    }
    else{
        return nil;
    }
    }

}


#pragma mark - Fetched Results Controller Section

-(NSFetchedResultsController*)fetchedResultsController{

    if (_fetchedResultsController != nil){
        return _fetchedResultsController;
    }
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc]init];
    NSManagedObjectContext *context = self.managedObjectContext;
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"ToDoItem" inManagedObjectContext:context];
    [fetchRequest setEntity:entity];
    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]initWithKey:@"todoDueDate" ascending:YES];
    NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc]initWithKey:@"todoName" ascending:YES];

    NSArray *sortDescriptors = [[NSArray alloc]initWithObjects:sortDescriptor,sortDescriptor1, nil];
    fetchRequest.sortDescriptors = sortDescriptors;
    _fetchedResultsController = [[NSFetchedResultsController alloc]initWithFetchRequest:fetchRequest managedObjectContext:context sectionNameKeyPath:@"sectionIdentifier" cacheName:nil];
    _fetchedResultsController.delegate = self;
    return _fetchedResultsController;
}


#pragma mark - Fetched Results Controller Delegates

-(void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
    [self.tableView beginUpdates];
}

-(void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
    [self.tableView endUpdates];

}

-(void) controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath{

    UITableView *tableView = self.tableView;

    switch (type) {
        case NSFetchedResultsChangeInsert:
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;
        case NSFetchedResultsChangeDelete:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;
        case NSFetchedResultsChangeUpdate:{

            ToDoItem *changeToDoItem = [self.fetchedResultsController objectAtIndexPath:indexPath];
            UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
            cell.textLabel.text = changeToDoItem.todoName;
            NSDate *fechaToDO = changeToDoItem.todoDueDate;

            NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
            [dateFormatter setDateFormat:@"EEEE, dd MMMM YYYY"];
            NSString *fechaToDo = [dateFormatter stringFromDate:fechaToDO];
            cell.detailTextLabel.text = fechaToDo;
        }
            break;
        case NSFetchedResultsChangeMove:
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }


}

-(void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type{

    switch (type) {
        case NSFetchedResultsChangeInsert:
            [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
        case NSFetchedResultsChangeDelete:
            [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
            break;
    }

}






// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return NO;
}



// Override to support editing the table view.







/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a story board-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}

 */
#pragma mark -
#pragma mark Content Filtering

-(void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope {
    self.searchResults = [[self.fetchedResultsController fetchedObjects] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
        ToDoItem * item = evaluatedObject;
        NSString* name = item.todoName;

        //searchText having length < 3 should not be considered
        if (!!searchText && [searchText length] < 3) {
            return YES;
        }

        if ([scope isEqualToString:@"All"] || [name isEqualToString:scope])  {
            return ([name rangeOfString:searchText].location != NSNotFound);
        }
        return NO; //if nothing matches
    }]];
}
#pragma mark -
#pragma mark UISearchDisplayController Delegate Methods

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    [self filterContentForSearchText:searchString scope:@"All"];
    return YES;
}

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
{
    [self filterContentForSearchText:[self.searchDisplayController.searchBar text] scope:@"All"];
    return YES;
}

- (IBAction)quickAddAction:(UIButton *)sender {


    UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:@"Add Task" message:@"Enter the task name" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    [alert addButtonWithTitle:@"Add"];
    [alert show];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1)
    {
        UITextField *todoText = [alertView textFieldAtIndex:0];
        NSLog(@"username: %@", todoText.text);

        ToDoItem *addToDoItem = [NSEntityDescription insertNewObjectForEntityForName:@"ToDoItem" inManagedObjectContext:self.managedObjectContext];
        addToDoItem.todoDueDate = [NSDate date];
        NSString *todoConvertido = todoText.text;
        addToDoItem.todoName = todoConvertido;
        [self.tableView reloadData];

    }
}
@end

您仅根据截止日期和名称进行排序,因此最旧条目的类别排在第一位。

条目必须首先根据您的sectionIdentifier进行排序

NSSortDescriptor *sortDescriptor0 = [[NSSortDescriptor alloc]initWithKey:@"sectionIdentifier" ascending:YES];
NSSortDescriptor *sortDescriptor1 = [[NSSortDescriptor alloc]initWithKey:@"todoDueDate" ascending:YES];
NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc]initWithKey:@"todoName" ascending:YES];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

UITableView 部分未按预期排序 的相关文章

  • TableView 中图像的大小不正确

    我正在使用来自 URL 的图像创建一个表视图 但图像不会调整到所有视图的大小 直到我将其按入行中 知道为什么会发生这种情况吗 这是一个自定义的表格视图 我的代码是 UITableViewCell tableView UITableView
  • 调用了 numberOfRowsInSection 但未调用 cellForRowAtIndexPath

    在我的表视图中节中的行数被调用两次但是cellForRowAtIndexPath不叫 我想在 tableView 中显示 Facebook 好友列表 如果 cellForRowAtIndexPath 调用我的问题就解决了 我在这里的数组中得
  • 延迟图像下载完成后更新 UITableViewCell

    异步下载单元格图像后 我在更新 UITableViewCells 时遇到一些问题 我正在使用自定义 UITableViewCells 如下所示 UITableViewCell tableView UITableView tableView
  • 在iOS中设置框架的原点

    我正在尝试以编程方式设置框架的原点 Method1 button frame origin y 100 方法二 CGRect frame button frame frame origin y 100 我尝试了方法 1 但它不起作用 显示错
  • 是否可以在增强现实应用程序中使用自定义 iOS UI 元素(例如 UILabel)

    我想知道是否可以使用像这样的 UI 元素UIButton UILabel在带有 ARKit 的增强现实应用程序中 如果您也对 UIView 子类的透明度模式感兴趣 请尝试我的示例https github com erikhric ar me
  • 我如何用 javascript/jquery 进行两指拖动?

    我正在尝试创建当有两个手指放在 div 上时拖动 div 的功能 我已将 div 绑定到 touchstart 和 touchmove 事件 我只是不确定如何编写这些函数 就像是if event originalEvent targetTo
  • 当自定义子视图处理触摸时防止 UITableView 滚动

    在我的 iOS 应用程序中 有一个 UITableView 其中一个单元格中包含一个自定义子视图 该单元格是一个交互式视图 它处理触摸事件 touchesBegan touchesEnded touchesMoved 以更新自身 问题是 当
  • 以编程方式向 UIButton 标签添加阴影

    我试图向按钮标签添加 1px 黑色阴影 但没有成功 我试过这个 self setTitleShadowOffset CGSizeMake 0 1 但我得到 请求非结构或联合中的成员 setTitleShadowOffset 任何建议都会很棒
  • 有没有办法阻止 iOS 上的 Safari 在关闭时清除网站的 cookie?

    我的移动网络应用程序的一位用户抱怨说 每次他关闭手机屏幕后使用该应用程序时 他都必须重新登录该应用程序 发生的情况是 当屏幕关闭时 或者当您通过双击主页按钮并滑开 Safari 来完全关闭 Safari 时 Safari 会清除该网站的 C
  • 如何从日期中获取小时、分钟和上午/下午? [复制]

    这个问题在这里已经有答案了 我尝试从日期中提取小时 分钟和上午 下午 但我得到 NULL 输出 我在下面显示了我的代码 请查看 NSString dateStr 29 07 2013 02 00am NSDateFormatter form
  • 如何更改便携式 xamarin ios 项目中的启动屏幕?

    我正在使用便携式 xamarin 形式 其中项目是 IOS 项目 在 IOS 项目中 我想创建闪屏 我在 ios 项目属性中添加了 Iphone 启动图像和 iPad 启动图像 当我运行该应用程序时 它显示默认的启动屏幕 我还尝试从 inf
  • CMSampleBufferSetDataBufferFromAudioBufferList 返回错误 12731

    我正在尝试捕获应用程序声音并将其传递给 AVAssetWriter 作为输入 我正在设置音频单元的回调以获取 AudioBufferList 问题始于将 AudioBufferList 转换为 CMSampleBufferRef 它总是返回
  • Swift:无法为“[UIViewController]”类型的值添加下标?

    我试图弄清楚如何在 Xcode 7 iOS9 上的 Swift 中解决此问题 并且我也遇到此错误 无法为 UIViewController 类型的值添加下标 索引类型为 Int 任何建议表示赞赏 谢谢 My code func indexP
  • AFNetworking 上传图片

    我看过一些例子 但我认为我的问题可能出在 PHP 中 我正在尝试使用 AFNetworking 将图像从 iPhone 上传到服务器 这是我的 obj c 代码 IBAction uploadButtonClicked id sender
  • 你如何在react-native中实现捏合缩放?

    我一直在研究 PanResponder 我当前的工作假设是 我将检测是否有两个触摸正在向外移动 如果是 则增加元素大小onPanResponderMove功能 这似乎是一种混乱的方法 有没有更顺畅的方法呢 如果您只需要简单的捏缩放功能 只需
  • ios Vision VNImageRequestHandler方向问题

    我正在尝试使用相机通过相机检测脸部VNImageRequestHandler iOS 愿景 当我在横向模式下用相机指向照片时 它会检测到面部 但方向模式相反 let detectFaceRequestHandler VNImageReque
  • PhoneGap 1.4 封装 Sencha Touch 2.X - 性能怎么样?

    我正在构建一个多平台平板电脑应用程序 仅使用其 Webview 使用 Phonegap 1 4 对其进行包装 然后使用 Sencha Touch 2 框架发挥我的魔力 我所说的多平台是指 iOS 5 X 和 Android 3 0 目前 到
  • 使用prepareForSegue传递数据

    我试图将数据从viewController 1传递到viewController2 我有2个按钮和1个segue 因此有一个segue标识符 这2个按钮 按下时每个按钮应显示 1个标签用于显示标题 1个textView用于显示定义 我很难显
  • 将捕获的图像精确裁剪为 AVCaptureVideoPreviewLayer 中的外观

    我有一个使用 AV Foundation 的照片应用程序 我使用 AVCaptureVideoPreviewLayer 设置了一个预览层 它占据了屏幕的上半部分 因此 当用户尝试拍照时 他们只能看到屏幕上半部分看到的内容 这很好用 但是当用
  • 如何在 Swift 中创建 UIAlertView?

    我一直在努力在 Swift 中创建 UIAlertView 但由于某种原因我无法得到正确的语句 因为我收到此错误 找不到接受提供的 init 重载 论点 我是这样写的 let button2Alert UIAlertView UIAlert

随机推荐

  • 适用于 Mac 的单击一次部署

    正如标题所述 是否有与 Mac 上的 Click Once 应用程序部署等效的方法 我问这个问题是因为 Lion 附带的 Safari 版本已删除 DMG 磁盘映像 文件作为下载后打开的 安全文件类型 我工作的公司有一个相当特殊用途的应用程
  • 通过 BlackBerry 发送 POST 数据后获取 HTML 响应

    我需要在发送 POST 数据后从 URL 读取 HTML 响应 我已经有以下两个函数 但我不知道如何组合它们 以便我可以发送 POST 数据并获取响应 此函数获取标准 HTML 响应 public static String getData
  • Java Rest api 需要等待才能处理

    我有一个 Java Rest API 物联网设备将使用它来发送数据 每个设备都有一个时间段 比如 15 秒 与 API 进行通信 在该时间段内 可以有多个具有相同数据集的消息 我想要做的是 当 API 从设备接收到新消息时 它会等到时间段结
  • basic_ostringstream::str 悬空指针

    最近我发现了以下代码中的错误 ostringstream o o lt lt some string const char s o str c str empty string instead of expected some string
  • librosa.effect.Split的返回值很奇怪

    正如标题所示 这个函数的结果不符合逻辑 我不明白这个函数在做什么 例如 这里是一些可重现的代码 load sample audio filename librosa util example audio file audio sr libr
  • 推送到远程分支(无法更新引用)

    我有一个带有功能 初始更改分支的远程存储库 现在我想将一些文件从本地功能 初始更改分支推送到此远程分支 我浏览了一些关于推送到远程分支的帖子并尝试了一些方法 但我仍然遇到相同的错误 添加并提交后 我得到以下 git 状态 Sakibs Ma
  • Azure WebJobs SDK 服务总线死信队列

    使用 WebJobs SDK 时 将 BrokeredMessage 移动到死信队列的正确方法是什么 通常我只会调用 msg DeadLetter 但是 SDK 负责管理代理消息的生命周期 如果方法返回成功 它将调用 msg Complet
  • 如何在按下按钮后以动画方式显示 UIPickerView?

    我想在按下按钮后为 UIPickerView 制作动画 我已经将 UIPickerView 编码为隐藏在 viewDidLoad 上 并且在按下按钮后不会隐藏 但它的动画效果不像 ModalViewController 默认情况下的动画效果
  • 包更新到 Angular 5 最新版本,但 npm 未使用 Angular 模板在 Visual Studio 2017 中更新

    我已将 Visual Studio 2017 模板中的 Angular 4 更新为 Angular 5 我按照链接中的说明进行操作http www talkingdotnet com upgrade Angular 4 app Angula
  • 如何计算滚动 idxmax

    考虑pd Series s import pandas as pd import numpy as np np random seed 3 1415 s pd Series np random randint 0 10 10 list ab
  • 函数对象的好处?

    我知道STL中使用的函数对象只是简单的对象 我们可以像函数一样操作它 我可以说函数和函数对象的工作原理是相同的 如果这是真的 那么为什么我们应该使用函数对象而不是函数呢 主要好处是对函数对象 函子 的调用通常是可内联的 而对函数指针的调用通
  • AngularStrap 选项卡加载 html 片段

    我目前正在使用 Twitter Bootstrap 开发 AngularJS 项目 并尝试将我的 Bootstrap 指令转换为 Angular 我决定使用 AngularStrap 因为它提供了对 Bootstrap Select 的支持
  • 如果 c =a,b,c 的值是多少;

    int a 0 int b 1 int c a b int d a b 在初始化之外 逗号 ina b is the 逗号运算符 并评估为b 涉及行中的括号d造成这样的情况 所以该行实际上相当于 int d b 然而 在涉及c 这不是逗号运
  • 如何解决 Java Swing 登录窗口中的这些可视化问题?

    我是 Java Swing 的新手 但我遇到了一个问题 我必须创建一个登录窗口 灵感来自这样的图像 像这样 scilicet 窗口必须显示 2 个文本字段 用户在其中插入用户名和密码以及一个按钮来执行登录操作 好的 我认为这非常简单 我已经
  • bind_param 中的参数数量未知[重复]

    这个问题在这里已经有答案了 当您不知道要接收的参数数量时 你们会怎么做 例如 if a 1 filter AND u name if b 1 filter AND u address if c 1 filter AND u age if d
  • 将布尔值序列化为“1”和“0”而不是“true”和“false”

    我在上面找不到任何方法Boolean类将布尔值序列化为 1 和 0 而不是 true 和 false 有没有本地函数可以做到这一点 如果不是 最好的方法 最优化的方法 是什么 更新 我确实想制作一个String出于一个Boolean If你
  • 将上下文变量与 IBM Watson Conversation 中的实体进行比较

    在 Watson 对话对话框中 我创建了一个条件 就像是 if stored state states Florida AND preferred joint joint KFC then some response where store
  • 安卓。如何沿对象面向的方向移动对象(使用 Vector3 和四元数)

    我正在使用 libGDX 事实上对它来说相当新 和 Android 我想沿 3d 对象所面向的方向移动 使用一定的速度 我认为这是一个基本问题 但找不到直接答案 我有一个代表对象旋转 方向 的四元数 有一个代表对象位置的 Vector3 问
  • FreeTDS - tsql 连接,isql 失败

    我正在尝试连接到我的主机 Windows XP SQL Server 05 上的数据库 我的客户机器是 Ubuntu 10 04 我可以使用 tsql 连接并执行命令 但 isql 失败 以下是我的配置文件和错误消息 freetds con
  • UITableView 部分未按预期排序

    我正在使用带有自定义部分标题的 tableView 核心数据对象根据称为 sectionIdentifier 的瞬态属性的值显示在精确的部分上 一切都按预期工作 但各部分的顺序没有按我的预期响应 这应该是部分顺序 1 OVERDUE sec