views:

158

answers:

3

Hello I want the keyboad show automatically onload, but it did not work as i expect here is the code i use:

- (void)viewDidLoad {

    [super viewDidLoad];

    [seachBar2 setDelegate:self];

}

- (BOOL)Searchbar2ShouldReturn:(UISearchBar *)searchBar2 {

    [searchBar2 becomeFirstResponder];

    return YES;

}

Coud somebody will point me how to fix this thank you somuch

A: 
- (void)viewDidLoad {
    [super viewDidLoad];
    [seachBar2 setDelegate:self];
    [seachBar2 becomeFirstResponder];
}
Morion
No it still not work, it not show onload. :(I don´t know what language is that, i´m new with this.hmm
You might want to try overriding viewDidAppear instead (but I'm just guessing).
Kristopher Johnson
hmm How ? I got headach with this whole night..trying to look at google but no solution.so sad :(
yes I have tried overriding viewDidAppear instead of viewDidLoadbut still not work...the keyboard not slide and show at once, until I have to click on search bar then it show,,,hmmmm so stressss:(
A: 

Make sure searchBar2 in your code points (IBOutlet) to the searchBar in the Interaface Builder.

in your code: IBOutlet UISearchBar *searchBar2;

In IB: goto the search bar's Connections Inspector (apple-2) and drag the Referencing Outlet to File Owner and select searchBar2

Hope this helps.

Mihir Mathuria
Yeah, 5 have checked everything is done, but I don´t have any idea,why it would not slide and display onload....hmmmmshould i have some special lines of code ?
A: 

you do need to override viewDidAppear:, and verify it's actually being called (put a breakpoint or an NSLog() statement in there). You should also determine the language you're coding in (it's Objective C).

Your -Searchbar2ShouldReturn: method will never be called by the system. I think you may need to go back and work through a few of Apple's tutorials here; your grasp of the frameworks seems tenuous, at best.

Ben Gottlieb
oww!! Sound so complicate, I will try the best:)but thanks for comment and help...I really hope i will find solution.I guess i lake some lines of code.....hmmm