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

Appzyme

macrumors newbie
Original poster
Mar 29, 2011
6
0
I have created an app with a uiwebview. Now I want to allow the user to be able to change the URL by using a settings like interface. Any help with a solution would be greatly appreciated. So to be clear my webview is initially programmed for www.google.com and I want the user to be able to change to www.yahoo.com or www.whatever.com.
 
How u want them to change the URL, quite important, u want an adress bar, or u want a settings screen, where they can touch something, or whatever.
Please explain a bit more, and i might help u out there :)
 
How u want them to change the URL, quite important, u want an adress bar, or u want a settings screen, where they can touch something, or whatever.
Please explain a bit more, and i might help u out there :)

Thanks for the reply jnoxx! I want them to be able to press a button and then be taken to a settings screen where they can then modify the current url. Sure hope you can help.
 
Alright, thanks for the clarification.

So, what exactly are you seeking help for now? Is there some specific piece to your solution that you are seeking advice on? Or what?

I'm not sure how to create the settings view that contains the editable "text region" for the url to the webview and then how to connect this "text region" variable to [NSURL URLWithString:mad:"text region"]
 
Easy/most hack and slash coding like is.
On button, load a new modal view controller, load the text from the textfield into a NSUserDefaults, and allways make the label show the current NSuserDefaults too.
Tadaa :)
And if they press a button, dismiss modal view, and load the view from the user defaults ;)

But they are more cleaner ways of doing this :)
 
Easy/most hack and slash coding like is.
On button, load a new modal view controller, load the text from the textfield into a NSUserDefaults, and allways make the label show the current NSuserDefaults too.
Tadaa :)
And if they press a button, dismiss modal view, and load the view from the user defaults ;)

But they are more cleaner ways of doing this :)

Thanks jnoxx. I'm going to try and decode your suggestion :confused: But what are the cleaner ways to do this?
 
Last edited:
I said, cleaner, not easier ;)

Pop a modal screen, that should be fairly easy to figure out.
Put in a UITextfield, add the UITextField delegate to your H file.
on enter, or whatever, save the .text of the textfield into a string. and share that with your other view controller where u need it.
This is the real good way.
But most "beginning" programmers having trouble in Objective-C with sharing data between viewControllers. That's why i suggested to use the NSuserDefaults hack (just save it into the background kind off).
and then retrieve it in ur website URL thingy. :)
Any more questions?

PS: this doesn't mean you have to do it this way, just inputting here :)
 
You should be aware that Apple has some strict and oddball rules regarding webviews where the user can type in the URL. They require that any app with this feature be listed for age 17+ because it's possible to view p0rn with such an app.

I've never heard of a UI like you describe where the user can choose from among a set of URLs but if the user can type in the URL then this rule may come into effect. If instead you have a set of preset URLs that the user can choose from then maybe the rule won't apply.
 
That's why i suggested to use the NSuserDefaults hack

I wouldn't call using NSUserDefaults a hack. It is just one approach among many to data-persistence and comes with its own pros and cons. For example, one pro is that they provide an easy way to preserve values across runs of the applications and another is that they are backed up when synching with iTunes (so, you should be able to delete an application, restore from backup and the values contained in the user defaults should be restored as well).
 
I wouldn't call using NSUserDefaults a hack. It is just one approach among many to data-persistence and comes with its own pros and cons. For example, one pro is that they provide an easy way to preserve values across runs of the applications and another is that they are backed up when synching with iTunes (so, you should be able to delete an application, restore from backup and the values contained in the user defaults should be restored as well).

Interesting, learned something new today.
About the "hack", well. whatever, you're right x)
I just use it for like 1 integer, but for saving a bunch, I would recommand other ways :)
 
Interesting, learned something new today.
About the "hack", well. whatever, you're right x)
I just use it for like 1 integer, but for saving a bunch, I would recommand other ways :)

Thanks jnoxx and dejo! PhoneyDeveloper I'll keep that in mind for sure.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.