Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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
Iphone 搜索显示控制器框架_Iphone - Fatal编程技术网

Iphone 搜索显示控制器框架

Iphone 搜索显示控制器框架,iphone,Iphone,我正在代码中使用搜索显示控制器进行搜索。但这也带来了一些问题。当视图被加载时,搜索栏框架将离开视图,但每当我试图搜索某个内容时,它就会出现在我需要的适当框架中。我无法识别代码中的问题。我已经附上了图片,这将使你更清楚地了解这个问题 以下是用于搜索的代码: pragma mark UISearchDisplayController委托方法 } 如果有人知道如何设置搜索栏框架,请提供一些解决方案 谢谢大家。谢谢大家查看我的问题。通过以编程方式使用搜索栏而不是搜索显示控制器,我解决了这个问题

我正在代码中使用搜索显示控制器进行搜索。但这也带来了一些问题。当视图被加载时,搜索栏框架将离开视图,但每当我试图搜索某个内容时,它就会出现在我需要的适当框架中。我无法识别代码中的问题。我已经附上了图片,这将使你更清楚地了解这个问题

以下是用于搜索的代码:

pragma mark UISearchDisplayController委托方法 }

如果有人知道如何设置搜索栏框架,请提供一些解决方案


谢谢大家。

谢谢大家查看我的问题。通过以编程方式使用搜索栏而不是搜索显示控制器,我解决了这个问题

   - (void)handleSearchForTerm:(NSString *)searchTerm
    {
   searchbar.frame = CGRectMake(391, 28, 586, 44);
 [self setSavedSearchTerm:searchTerm];

if ([self searchResults] == nil)
{
    NSMutableArray *array = [[NSMutableArray alloc] init];
    [self setSearchResults:array];
}

[[self searchResults] removeAllObjects];

if ([[self savedSearchTerm] length] != 0)
{
    int i = 0;
    
    for (NSString *currentString in [[self contentsList]valueForKey:@"name"])
    {
        if ([currentString rangeOfString:searchTerm options:NSCaseInsensitiveSearch].location != NSNotFound)
        {
            [[self searchResults] addObject:currentString];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"id"]];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"category"]];
            NSString *searchcategory = [[[self contentsList]objectAtIndex:i] objectForKey:@"category"];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"flavour"]];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"price"]];
            [[self searchResults] addObject:[[[self contentsList]objectAtIndex:i] objectForKey:@"image"]];
          }
        i++;
       }
   }
 - (BOOL)searchDisplayController:(UISearchDisplayController *)controller 
 shouldReloadTableForSearchString:(NSString *)searchString
{
searchbar.frame = CGRectMake(391, 28, 586, 44); 
[self handleSearchForTerm:searchString];
return YES;
}

- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
{
searchbar.frame = CGRectMake(391, 28, 586, 44);
[self setSearchResults:nil];
[self setSavedSearchTerm:nil];
[[self itemstable_ipad]reloadData];
}

-(void)searchmethod
{
searchbar.frame = CGRectMake(391, 28, 586, 44);
[self setContentsList:categoryarray_ipad];
if ([self savedSearchTerm])
   {
    [[[self searchDisplayController] searchBar] setText:[self savedSearchTerm]];
   }
}