Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AbhishekApple

macrumors member
Original poster
Aug 5, 2010
86
0
I have following code where in only search bar,fixedspacebar is visible on the toolbar but uitextfield is not visible.....
Also fixedspace bar should not be visible in runtime but it is visible and can be tapped as button....
Code:
- (void)viewDidLoad {
    [super viewDidLoad];
	//self.view.backgroundColor =[UIColor blackColor];

	toolBar =[[UIToolbar alloc]init];

	srcBar = [[UISearchBar alloc] init];
	txtPrice = [[UITextField alloc] init];
	btnSearchBar = [[UIBarButtonItem alloc]initWithCustomView:srcBar];
	btntxtPriceBar = [[UIBarButtonItem alloc]initWithCustomView:txtPrice];
	fixedBar = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonSystemItemFixedSpace target:nil action:nil];
	
	[txtPrice setPlaceholder:@"helloc"];
	[toolBar setItems:[NSArray arrayWithObjects:btnSearchBar,btntxtPriceBar,fixedBar,nil]];


	btnSearchBar.width = 200;
	btntxtPriceBar.width = 200;
        fixedBar.width = 410;
....
.....
...
}
Please suggest on this.....
 
Code:
...
btntxtPriceBar.width = 200;
[COLOR="Red"][txtPrice sizeToFit];[/COLOR]
...
[toolBar setItems:[NSArray arrayWithObjects:btnSearchBar,btntxtPriceBar,fixedBar,nil]];
...

This works. Hope this helps :)
 
Code:
...
btntxtPriceBar.width = 200;
[COLOR="Red"][txtPrice sizeToFit];[/COLOR]
...
[toolBar setItems:[NSArray arrayWithObjects:btnSearchBar,btntxtPriceBar,fixedBar,nil]];
...

This works. Hope this helps :)

Thanks ianray.....but the FixedSpace button problem is not yet resolved...
FixedSpace button is visible on runtime and can be tapped....which property needs to be set for it....
 
Can you post the entire viewDidLoad method?

EDIT:

P.S. For the fixed space, you should use the following instead:

fixedBar = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];

If you had looked at the possible choices for style: in your call to initWithTitle:style:target:action:, you'd see that UIBarButtonSystemItemFixedSpace is not a valid choice.
 
Last edited:
P.S. For the fixed space, you should use the following instead:

If you had looked at the possible choices for style: in your call to initWithTitle:style:target:action:,
you'd see that UIBarButtonSystemItemFixedSpace is not a validchoice.

Thanks dejo this worked....ur explanation helped...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.