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

mcnuggets

macrumors newbie
Original poster
Jan 2, 2009
18
0
So I'm following this browser sample and found two problems that I can't figure out on resolving.

Problems:

1) I notice on the address bar, I always have to type in: "http://www. {URL NAME} . com". I want it so that I don't have to type in "http://" everytime I want to go to a URL.

2) I go to google.com on the webview. Once I'm on google's website, I click on the Google Search text bar to type but my keyboard that pops up doesn't display the keyboard layout.

Please help me on this because this is driving me bananas.

Source code that I'm playing with is located on:
http://icodeblog.com/wp-content/uploads/2008/12/icodebrowser.zip
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
1) I notice on the address bar, I always have to type in: "http://www. {URL NAME} . com". I want it so that I don't have to type in "http://" everytime I want to go to a URL.
Before doing anything with the addressBar.text, check to see if it starts with 'http://'. If it does, continue. If it doesn't, add it.

I'll look at #2 later.
 

mcnuggets

macrumors newbie
Original poster
Jan 2, 2009
18
0
Thanks for replying. But what if you just want a default of "http://" everytime in the addressBar? So basically as a default... http:// is automatically insert everytime. I don't need error correction.

I'm guessing it's in this syntax on the "gotoAddress" action. Is the syntax this:

NSURL *url = [NSURL URLWithString:[@"http://www.%@", addressBar text]];

I tried that string and it wont work. Any help?
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I tried that string and it wont work. Any help?
Won't work? In which way? Do you get an error?

Also, you need to reference it as [addressBar text] and I don't think you can build the string as shown within the URLWithString. Try this instead:
Code:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.%@", [addressBar text]]];
 

mcnuggets

macrumors newbie
Original poster
Jan 2, 2009
18
0
Won't work? In which way? Do you get an error?

Also, you need to reference it as [addressBar text] and I don't think you can build the string as shown within the URLWithString. Try this instead:
Code:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.%@", [addressBar text]]];


You're just too awesome. It works. :D

By the way, were you able to figure out a solution to my 2nd problem?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.