Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 05-20-2010, 02:45 AM   #1 (permalink)
Erik Carlson
 
Join Date: Feb 2010
Location: London
Posts: 3
ErikCarlson is on a distinguished road
Default setting enablesReturnKeyAutomatically on UISearchBar

Hi There,

I want the search button in the keyboard from my UISearchBar to have the search button enabled all the time. If this was any old UITextField (not a search bar) the property would be enablesReturnKeyAutomatically.

I have tried setting this using the example given at Apple - Support - Discussions - UISearchBar: enable search button by ...

which suggests:

Code:
UITextField *searchTextField ; 
    searchTextField = [[searchBar subviews]objectAtIndex:0];
    searchTextField.enablesReturnKeyAutomatically = NO ;

Should work.

unfortunately it crashes:

Code:
2010-05-20 08:36:18.284 ARemote[5929:207] *** -[UISearchBarBackground setEnablesReturnKeyAutomatically:]: unrecognized selector sent to instance 0x3b31980
2010-05-20 08:36:18.284 ARemote[5929:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UISearchBarBackground setEnablesReturnKeyAutomatically:]: unrecognized selector sent to instance 0x3b31980'
I have also tried
Code:
((UITextField *)[(NSArray *)[searchBar subviews] objectAtIndex:0]).enablesReturnKeyAutomatically = NO;

Which gives similar results.

Any ideas?

Cheers
Erik

Last edited by ErikCarlson; 05-20-2010 at 02:48 AM.
ErikCarlson is offline   Reply With Quote
Old 11-15-2010, 09:25 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 8
Fanagame is on a distinguished road
Default

Quote:
Originally Posted by ErikCarlson View Post
Hi There,

I want the search button in the keyboard from my UISearchBar to have the search button enabled all the time. If this was any old UITextField (not a search bar) the property would be enablesReturnKeyAutomatically.

I have tried setting this using the example given at Apple - Support - Discussions - UISearchBar: enable search button by ...

which suggests:

Code:
UITextField *searchTextField ; 
    searchTextField = [[searchBar subviews]objectAtIndex:0];
    searchTextField.enablesReturnKeyAutomatically = NO ;

Should work.

unfortunately it crashes:

Code:
2010-05-20 08:36:18.284 ARemote[5929:207] *** -[UISearchBarBackground setEnablesReturnKeyAutomatically:]: unrecognized selector sent to instance 0x3b31980
2010-05-20 08:36:18.284 ARemote[5929:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UISearchBarBackground setEnablesReturnKeyAutomatically:]: unrecognized selector sent to instance 0x3b31980'
I have also tried
Code:
((UITextField *)[(NSArray *)[searchBar subviews] objectAtIndex:0]).enablesReturnKeyAutomatically = NO;

Which gives similar results.

Any ideas?

Cheers
Erik
I guess you've already found an answer by know, but just in case (or for other folks having the same problem) :

Code:
for (UIView *subview in mySearchBar.subviews) {
		if ([subview isKindOfClass:NSClassFromString(@"UITextField")]) {
			((UITextField *)subview).enablesReturnKeyAutomatically = NO;
		}
	}
Fanagame is offline   Reply With Quote
Old 12-30-2010, 04:27 AM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Location: The Hague, Netherlands
Posts: 8
Matthijs is on a distinguished road
Send a message via ICQ to Matthijs
Default

Quote:
Originally Posted by Fanagame View Post
I guess you've already found an answer by know, but just in case (or for other folks having the same problem) :

Code:
for (UIView *subview in mySearchBar.subviews) {
		if ([subview isKindOfClass:NSClassFromString(@"UITextField")]) {
			((UITextField *)subview).enablesReturnKeyAutomatically = NO;
		}
	}
Works great, thanks!
Matthijs is offline   Reply With Quote
Reply

Bookmarks

Tags
enablesreturnkey, uisearchbar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 376
8 members and 368 guests
comicool, husthlj, illogical, LegionMD, LunarMoon, mer10, Murphy, padsoftware
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,677
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, husthlj
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:10 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0