UIWebView ~ Linking a button?? - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 20, 2011, 05:32 PM   #1
alexpja
macrumors member
 
Join Date: Mar 2010
UIWebView ~ Linking a button??

Hi there, I am making a newsreader application where I want to have a button on the toolbar on the bottom of my screen to take me back to my website... how can I do this? I have the back, forward, refresh, and stop buttons all good and working, just need this button :/
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 20, 2011, 05:36 PM   #2
hayesk
macrumors 65816
 
Join Date: May 2003
What problem are you having?

Add a button, set the target and action to a method on your view controller that tells your web view to load the URL of your home page.
hayesk is offline   0 Reply With Quote
Old Jan 20, 2011, 05:37 PM   #3
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by hayesk View Post
What problem are you having?

Add a button, set the target and action to a method on your view controller that tells your web view to load the URL of your home page.
Here's the problem... I am a total newbie and do not like to read books, and cannot find anything like this on Google :S so I'd love any help I can get o_o
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6

Last edited by alexpja; Jan 20, 2011 at 05:45 PM.
alexpja is offline   0 Reply With Quote
Old Jan 20, 2011, 06:26 PM   #4
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by hayesk View Post
What problem are you having?

Add a button, set the target and action to a method on your view controller that tells your web view to load the URL of your home page.
What did he mean... D:
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 20, 2011, 06:26 PM   #5
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by alexpja View Post
Here's the problem... I am a total newbie and do not like to read books, and cannot find anything like this on Google :S so I'd love any help I can get o_o
First, of all: welcome! we were all newbies at some point. There's nothing wrong with that.

If you ask for specific help, you'll get more support. Just realize that probably very few here are going to just give you a solution you can copy-and-paste.

If you don't like to read books, fine. But if you want to become a good programmer, you're going to want to be comfortable reading, because it will be quicker for you to be able to find and interpret pre-existing information rather than seeking help from others constantly. Just some advice as you start out.

So, if books aren't for you, what is? That will help us tailor our answers to an approach you prefer.
__________________
dejo is offline   0 Reply With Quote
Old Jan 20, 2011, 06:31 PM   #6
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by dejo View Post
...
So, if books aren't for you, what is? That will help us tailor our answers to an approach you prefer.
Well, I am making an app where you can view through a selection of websites to read, and I need a button on the toolbar where the back, forward, refresh, and stop buttons are to link back to the original website where they can go through the selection again without having to press back too much... I need a simple, copy-n-paste code since I will not be able to combine this piece of code, and this piece of code to make this piece... etc. e.e
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 20, 2011, 06:34 PM   #7
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by alexpja View Post
I need a simple, copy-n-paste code since I will not be able to combine this piece of code, and this piece of code to make this piece... etc. e.e
Well, good luck with that!
__________________
dejo is offline   0 Reply With Quote
Old Jan 20, 2011, 06:36 PM   #8
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by dejo View Post
Well, good luck with that!
o_o That's helpful e.e
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 20, 2011, 06:39 PM   #9
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by alexpja View Post
o_o That's helpful e.e
Sorry, I couldn't be more helpful but I wanted to wish you well in your quest. I suspect you're gonna need it.
__________________
dejo is offline   0 Reply With Quote
Old Jan 20, 2011, 06:40 PM   #10
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by dejo View Post
Sorry, I couldn't be more helpful but I wanted to wish you well in your quest. I suspect you're gonna need it.
Of course I am... since there is no one who can help me with this :/ Can you? o:
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 20, 2011, 06:45 PM   #11
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by alexpja View Post
Can you? o:
Perhaps. As you can tell, I'm not about to give you copy-and-paste code. As robbieduncan likes to say, "That's not programming". But if there is some other approach to learning besides books that you prefer, please let us know and we'll see what we can do.

Also, make sure you've stopped by the Guides and Stickies at the top of this very forum.
__________________
dejo is offline   0 Reply With Quote
Old Jan 20, 2011, 06:46 PM   #12
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by dejo View Post
Perhaps. As you can tell, I'm not about to give you copy-and-paste code. As robbieduncan likes to say, "That's not programming". But if there is some other approach to learning besides books that you prefer, please let us know and we'll see what we can do.
Searched through Google, found nothing... Will look at that sticky... Thanks anyway v.v

EDIT:

Quote:
Originally Posted by eddietr View Post
If I'm understanding your problem correctly, you want each of the buttons on the left to cause the web view on the right to load a particular URL. If that's the case, one reasonable way to do that is to create a view controller for this view (you may have done that already) which has an action (or actions) to which you would connect each button.

The view controller would have an outlet to the web view so it can send messages to that view to load URLs as needed.

Assuming I'm understanding the question correctly...
This is what I meant... except I do not know what the view controller is and I do not know how to work with it, I know how to make actions and outlets though...
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6

Last edited by alexpja; Jan 20, 2011 at 06:56 PM.
alexpja is offline   0 Reply With Quote
Old Jan 20, 2011, 09:45 PM   #13
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by alexpja View Post
...except I do not know what the view controller is...
If you don't know what a view controller is I think it's time to step away from the real coding and go learn the basics of iPhone programming. Without a good foundation of the fundamentals, it is going to be more difficult to move forward with even fairly simple tasks like you are attempting to do. In other words, you must learn to walk before you can run.
__________________
dejo is offline   0 Reply With Quote
Old Jan 20, 2011, 11:01 PM   #14
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by dejo View Post
If you don't know what a view controller is I think it's time to step away from the real coding and go learn the basics of iPhone programming. Without a good foundation of the fundamentals, it is going to be more difficult to move forward with even fairly simple tasks like you are attempting to do. In other words, you must learn to walk before you can run.
Okay e.e.... Now where can I find the basics of iOS programming that are simple enough for someone like me (I do not even understand the iOS Reference Library).... e.e
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 21, 2011, 01:52 AM   #15
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Well, you still haven't told us what learning style you prefer (all we know is what you don't like: books), so it's hard to make recommendations. Was there nothing in the FAQ that appealed to you?
__________________
dejo is offline   0 Reply With Quote
Old Jan 21, 2011, 07:20 AM   #16
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by dejo View Post
Well, you still haven't told us what learning style you prefer (all we know is what you don't like: books), so it's hard to make recommendations. Was there nothing in the FAQ that appealed to you?
The learning style I prefer is more like... online tutorials that are understandable and easy to learn from... not like the iOS reference library :S

In the FAQ (which I think you meant is the guides and stickes on top of the forum), there was nothing that appealed to me... and also, I am trying to get this done as soon as possible so :S and sorry for any misunderstandings when reading my replies, Polish is my first language :3

Also, with books (I read books all the time, just hate them for learning resources) I cannot concentrate on what I am reading and it is harder for me to follow with what the book says...
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 21, 2011, 08:53 AM   #17
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by alexpja View Post
The learning style I prefer is more like... online tutorials that are understandable and easy to learn from... not like the iOS reference library :S

In the FAQ (which I think you meant is the guides and stickes on top of the forum), there was nothing that appealed to me... and also, I am trying to get this done as soon as possible so :S and sorry for any misunderstandings when reading my replies, Polish is my first language :3
The iPhone Developer FAQ (which is a Sticky of this forum) contains a link to some online tutorials. Did you give them a look? Also, I've found the iCodeBlog tutorials to be quite helpful (although the oldest articles on the simplest things may be somewhat out-of-date now).

As for trying to get this done as soon as possible, what is the reason behind the urgency? Do you have a deadline or something?
__________________
dejo is offline   0 Reply With Quote
Old Jan 21, 2011, 09:11 AM   #18
nickculbertson
macrumors regular
 
Join Date: Nov 2010
Location: Nashville, TN
in your .h
Code:
- (IBAction)mySite;
in your .m
Code:
- (IBAction)mySite { 
	[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.youtube.com"]]];
}

add a bar button item in interface builder and connect it to mySite action.

Nick
nickculbertson is offline   0 Reply With Quote
Old Jan 21, 2011, 03:46 PM   #19
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by nickculbertson View Post
in your .h
Code:
- (IBAction)mySite;
in your .m
Code:
- (IBAction)mySite { 
	[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.youtube.com"]]];
}

add a bar button item in interface builder and connect it to mySite action.

Nick
Thank you so much! Thanks for helping me...

EDIT: Should I place it between:
Code:
@interface WebAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
	UIWebView *webView;
}
? (.h) and where in my .m?

Quote:
Originally Posted by dejo View Post
As for trying to get this done as soon as possible, what is the reason behind the urgency? Do you have a deadline or something?
Yes.
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 21, 2011, 03:54 PM   #20
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by alexpja View Post
Yes.
If it is homework you should say so. If you are being paid to do it you should sub-contract it out.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old Jan 21, 2011, 04:16 PM   #21
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by Cromulent View Post
If it is homework you should say so. If you are being paid to do it you should sub-contract it out.
Yes its homework... o.o
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 21, 2011, 04:56 PM   #22
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by alexpja View Post
Yes its homework... o.o
Well, you should be very thankful that nickculbertson did half your homework for you.
__________________
dejo is offline   0 Reply With Quote
Old Jan 21, 2011, 05:41 PM   #23
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by dejo View Post
Well, you should be very thankful that nickculbertson did half your homework for you.
I am. I need to figure out where to put the code :S
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote
Old Jan 21, 2011, 05:48 PM   #24
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by alexpja View Post
I am. I need to figure out where to put the code :S
How did you get the "back, forward, refresh, and stop buttons all good and working"? Maybe try the same approach?
__________________
dejo is offline   0 Reply With Quote
Old Jan 21, 2011, 06:52 PM   #25
alexpja
Thread Starter
macrumors member
 
Join Date: Mar 2010
Quote:
Originally Posted by dejo View Post
How did you get the "back, forward, refresh, and stop buttons all good and working"? Maybe try the same approach?
Well, I went into IB, and pressed the button. Then, CTRL-clicked the UIWebView, and clicked the action for that button. I cannot do that for my button, so please just help me here and stop pointing me to FAQs and tutorials when they will not help my problem e.e
__________________
 MacBook Pro 13" 2.26GHz, 4GB RAM, Mid-Summer 2009
 Black MacBook 13" 2.4GHz, 6GB RAM, 2008
 T-Mobile Black 5s 16GB, iOS 7.0.6
alexpja is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Closing a UIWebView? Tander iPhone/iPad Programming 6 Jan 2, 2014 06:32 AM
Linking a button or image to a url... furycd001 Mac Programming 7 May 17, 2013 05:52 PM
iPhone 4 Sleep/wake button, vibrate button, and volume button not responsive McEggrolls iPhone 6 Sep 20, 2012 09:16 AM
Nitro Engine in UIWebView DSchwartz88 Jailbreaks and iOS Hacks 3 Jun 28, 2012 09:16 PM
UIWebView Help drewgarcia23 iPhone/iPad Programming 1 Jun 5, 2012 09:50 AM

Forum Jump

All times are GMT -5. The time now is 12:54 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC