• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Programmatically add a UISearchBar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Programmatically add a UISearchBar


  • Subject: Programmatically add a UISearchBar
  • From: Nala Gnirut <email@hidden>
  • Date: Fri, 30 Oct 2009 11:12:44 +0100

Hi all,
I'm trying to programmatically add UISearchBar to my UITableView header:

- (void)viewWillAppear:(BOOL)animated {

	[...]

	if (!self.tableView.tableHeaderView) {

		// Add the search bar
		searchBar = [[UISearchBar alloc] init];
		self.tableView.tableHeaderView = searchBar;

		searchController = [[UISearchDisplayController alloc]
							initWithSearchBar:searchBar
							contentsController:self];

		[searchController setActive:YES animated:NO];
		[searchController setActive:NO animated:NO];

		[...]

	}

	// Hide the searchbar
	[self.tableView setContentOffset:CGPointMake(0,44)];

	[...]

}

Unless I activate/deactivate the searchController:

[searchController setActive:YES animated:NO];
[searchController setActive:NO animated:NO];

the searchBar is not correctly shown on table header.

Is there a more elegant / correct way to avoid this glitch?

Thanks in advance.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Trying blocks
  • Next by Date: sizeWithAttributes Cutting Off Drop Shadow, Italic Mask?
  • Previous by thread: Re: xml object memory issue
  • Next by thread: sizeWithAttributes Cutting Off Drop Shadow, Italic Mask?
  • Index(es):
    • Date
    • Thread