UA-17470720-3

Jump to content


Photo
- - - - -

Prevent SCSearchViewController from Creating UITableView

view-controllers models general

  • Please log in to reply
1 reply to this topic

#1 Bill1348790289

Bill1348790289

    Starting Out

  • STV 3.0 Pro
  • Pip
  • 4 posts
Reputation: 1
Good

Posted 30 August 2013 - 08:02 AM

Hello ,

I have a UISearchBar and a tableview in an xib and wired the searchbar and tableview but I did NOT create IBOutlet Properties (I tried creating properties but that did not work either).

 

When I tap the search bar A new searchbar with a 1 row tableview appears on top of my existing searchbar and table view.

 

See attached. The problem is that the formatting of my table is messed up where the top row appears in the NEW table view and my existing.

 

Can I prevent the New search bar and table OR just the table view from appearing ? I Like how the New search bar automatically filters the tableview on each keystroke rather than me creating search logic.

 

 

Thanks 

 

  

 

SCArrayOfObjectsModel *booksModel = [SCArrayOfObjectsModel modelWithTableView:self.tableView entityDefinition:booksDef];

 

   

    booksModel.searchBar = self.searchBar;

    //search by book names

    booksModel.searchPropertyName = _entityAttribute;

    booksModel.autoSortSections = YES;

 

 

 

booksModel.sectionActions.cellForRowAtIndexPath = ^SCCustomCell*(SCArrayOfItemsSection *itemsSection, NSIndexPath *indexPath)

{

// Create & return a custom cell based on the cell in BookOverviewCell

NSString *bindingsString = @"1:title;2:author;3:pix"; // 1,2,3 are the control tags

 

SCCustomCell *bookOverviewCell = [SCCustomCell cellWithText:nil objectBindingsString:bindingsString nibName:@"BookOverviewCell"];

bookOverviewCell.themeStyle = @"whiteCell";

 

 

booksModel.cellActions.willConfigure = ^(SCTableViewCell *cell, NSIndexPath *indexPath)

{

 

 

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {

 

UILabel *l1  = (UILabel *)[cell viewWithTag:1];

l1.font = [UIFont fontWithName:@"ChalkboardSE-Regular" size:12];

UILabel *l2  = (UILabel *)[cell viewWithTag:2];

l2.font = [UIFont fontWithName:@"ChalkboardSE-Regular" size:12];

 

 

}

 

UIImageView *imageView = (UIImageView *)[cell viewWithTag:3];

NSManagedObject *mo = (NSManagedObject *)cell.boundObject;

  NSData *mydata = (NSData *)[mo valueForKey:@"pix"];

 

UIImage *im =  [UIImage imageWithData:mydata];

     imageView.image  = im;

 

 

UIView *bgColorView = [[UIView alloc] init];

[bgColorView setBackgroundColor:[UIColor orangeColor]];

[cell setSelectedBackgroundView:bgColorView];

 

};

 

 

 

return bookOverviewCell;

};

 

 

 



#2 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 04 September 2013 - 11:26 AM

Greetings Program!

 

Do not use the SCSearchViewController if you want to use your own search bar.

 

On my custom search, this works fine:

.h
@interface ViewController : SCTableViewController <UISearchBarDelegate>

@property(nonatomic, retain) IBOutlet UISearchBar *searchBar;

.m
@synthesize searchBar;

- (void)searchBarSearchButtonClicked:(UISearchBar *)search
{
    // Hide the keyboard.
    [self.view endEditing:YES];
    
    NSLog(@"\n-------------------\nSearch for: %@\n-------------------\n", search.text);
    
    // Handle custom filtering.
}

 

 

If I switch it to this then I experience the normal handling of the SCSearchViewController where the view slides up and the tableview is darkened:

@interface ViewController : SCSearchViewController <UISearchBarDelegate>

 

Wg


Edited by wizgod, 04 September 2013 - 11:34 AM.

P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)






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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users