resize UISearchBar - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 13, 2012, 12:49 PM   #1
kikko088
macrumors member
 
Join Date: Oct 2010
Location: Italy
resize UISearchBar

Hi at all I have a problem, I need to change uisearchbar frame, I try to di it in 2 way, the first time putting uisearchbar inside the tableview I can't change the frame with [uisearchbar appearance] or creating an IBOutlet property and changing the frame of this property.

The second way I use is to create programmatically an uisearchbar and uisearchcontroller I can resize searchbar but if I don't initsearchcontroller with this searchbar I can't search anything, but If I init earchcontroller with this searchbar it take the default frame size.

this is my code:

Code:
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(56, 68, 200, 44)];
self.searchBar.delegate = self;

self.mySearchDisplayController = [[UISearchDisplayController alloc ]initWithSearchBar:self.searchBar contentsController:self];

self.mySearchDisplayController.delegate = self;
self.mySearchDisplayController.searchResultsDataSource = self;
self.mySearchDisplayController.searchResultsDelegate = self;

for (UIView *subview in self.searchBar.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
[subview removeFromSuperview];
break;
}
if ([subview isKindOfClass:[UITextField class]]) {
// Do your text field customisation in here
[(UITextField *)subview setTextColor:[UIColor redColor]];
}
}

[self.searchBar setBackgroundColor:[UIColor clearColor]];

[self.mainView addSubview:self.searchBar];

can you help me?
__________________
iTouch 1G
kikko088 is offline   0 Reply With Quote
Old Dec 13, 2012, 05:30 PM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Have you tried changing the searchBar's frame after calling initWithSearchBar:contentsController:?
__________________
dejo is offline   0 Reply With Quote
Old Dec 14, 2012, 04:24 AM   #3
kikko088
Thread Starter
macrumors member
 
Join Date: Oct 2010
Location: Italy
yes I try but nothing, I get something good playing with the frame on the delegate method but however is not the right way because the frame is adjust after a moment.
FOR NOW I find a solution on specific case adjusting the frame of table (not of single search bar)
__________________
iTouch 1G
kikko088 is offline   0 Reply With Quote
Old Dec 14, 2012, 08:40 AM   #4
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by kikko088 View Post
...however is not the right way because the frame is adjust after a moment.
Well, you need to troubleshoot what is causing your frame to be readjusted without your "permission", as it were.
__________________
dejo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Resize App? weezin iPad Apps 2 Nov 28, 2013 06:29 AM
Cant Resize Partition xpmrz Mac Basics and Help 2 Oct 19, 2013 09:59 AM
Word 2008: Cannot Resize tables (with resize pointer) mujimuji Mac Applications and Mac App Store 1 Jul 31, 2013 12:09 PM
Can't resize jakesaunders27 OS X 10.8 Mountain Lion 3 Jul 15, 2013 04:26 PM
iPad: Can someone resize this for the iPad ? GeorgieAcevedo UI Customization 1 Nov 7, 2012 02:22 AM

Forum Jump

All times are GMT -5. The time now is 01:58 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC