UA-17470720-3

Jump to content


Photo
- - - - -

Two SearchBars in SCSearchViewController

view-controllers

  • Please log in to reply
6 replies to this topic

#1 TODD GARLAND

TODD GARLAND

    Experienced Member

  • STV 4.0 Pro
  • PipPipPipPip
  • 69 posts
Reputation: 21
Excellent

Posted 04 January 2015 - 08:25 AM

Gents,

 

Just implemented SCSearchViewController in new release.

 

I do not have tableview just SCArrayOfObjectsModel *objectsModel.

 

I have stripped everything out.

 

When the SCSearchViewController launches it contains two search bars.

 

Anyone experienced this/know of fix.

 

Thanks

 

Todd



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 05 January 2015 - 11:13 AM

Hi Todd,

 

I believe this might be a bug since STV 4.0 now provides its own search bar as is required by iOS 8's search controller (perhaps we should now deprecate SCSearchViewController). Please use a regular SCTableViewController, then simply set

 

objectsModel.enableSearchController = YES;

 

Please let me know if this works for you.



#3 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 30 October 2015 - 08:08 AM

Hi Todd,

 

I believe this might be a bug since STV 4.0 now provides its own search bar as is required by iOS 8's search controller (perhaps we should now deprecate SCSearchViewController). Please use a regular SCTableViewController, then simply set

 

 

objectsModel.enableSearchController = YES;

 

Please let me know if this works for you.

 

Hi Tarek,

 

I had the same problem and did what you suggested. But introducing enableSearchController = YES now breaks the sort section of the tableview.

 

As you can see on the screen shots, the left was before enableSearchController is applied.
 
 
Looking forward to hear from you.


#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 31 October 2015 - 06:26 AM

Hi Chau,

 

Thank you very much for reporting. Would you please post the code responsible for your sorting?

 

Thanks again!



#5 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 31 October 2015 - 08:32 PM

Here is the code. I am using 5.1.3.

 


    SCArrayOfObjectsModel *objectsModel = [[SCArrayOfObjectsModel alloc] initWithTableView:self.tableView entityDefinition:personDef];
    objectsModel.searchPropertyName = @"lastName;firstName;countryName";
    objectsModel.editButtonItem = self.editButton;
    objectsModel.hideSectionHeaderTitles = NO;
    objectsModel.autoSortSections = YES;

    objectsModel.modelActions.sectionHeaderTitleForItem = ^NSString*(SCArrayOfItemsModel *itemsModel, NSObject *item, NSUInteger itemIndex)
    {
        // Cast not technically neccessary, done just for clarity
        NSManagedObject *managedObject = (NSManagedObject *)item;
        
        NSString *objectName = [managedObject valueForKey:@"lastName"];
        
        if (objectName.length == 0)
        {
            return @"";
        }
        
        // Return first charcter of objectName
        return [[objectName substringToIndex:1] uppercaseString];
    };



#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 03 November 2015 - 09:03 AM

Hi Chau,

 

I couldn't replicate your issue at all in our bundled TasksApp sample. Here is the code I used:

 

//MasterViewController.m
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    SCArrayOfObjectsModel *tasksModel = [SCArrayOfObjectsModel modelWithTableView:self.tableView];
    
    tasksModel.modelActions.sectionHeaderTitleForItem = ^NSString*(SCArrayOfItemsModel *itemsModel, NSObject *item, NSUInteger itemIndex)
    {
        NSString *taskName = (NSString *)[item valueForKey:@"name"];
        
        // Return first charcter of objectName
        return [[taskName substringToIndex:1] uppercaseString];
    };
    self.tableViewModel = tasksModel;
    
    tasksModel.dataFetchOptions.sort = YES;
    tasksModel.enableSearchController = YES;
}

 

Would you please try this out and let me know if we're on the same page here? I am assuming you're using the latest version of STV.



#7 CHAU LE

CHAU LE

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 32 posts
Reputation: 2
Good

Posted 04 November 2015 - 02:20 AM

Hi Tarek,

 

When I moved the line

 

tasksModel.enableSearchController = YES;

 

below the sectionHeaderTitleForItem block then all is well.

 

Thanks for your help.







Also tagged with one or more of these keywords: view-controllers

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users