UIWebView ~ Linking a button??

Discussion in 'iOS Programming' started by alexpja, Jan 20, 2011.

  1. macrumors member

    Joined:
    Mar 22, 2010
    #1
    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? :confused: I have the back, forward, refresh, and stop buttons all good and working, just need this button :/
     
  2. macrumors 65816

    Joined:
    May 20, 2003
    #2
    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.
     
  3. alexpja, Jan 20, 2011
    Last edited: Jan 20, 2011

    thread starter macrumors member

    Joined:
    Mar 22, 2010
    #3
    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
     
  4. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #4
    What did he mean... D:
     
  5. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    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.
     
  6. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #6
    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
     
  7. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Well, good luck with that!
     
  8. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #8
    o_o That's helpful e.e
     
  9. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    Sorry, I couldn't be more helpful but I wanted to wish you well in your quest. I suspect you're gonna need it. ;)
     
  10. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #10
    Of course I am... since there is no one who can help me with this :/ Can you? o:
     
  11. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
    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.
     
  12. alexpja, Jan 20, 2011
    Last edited: Jan 20, 2011

    thread starter macrumors member

    Joined:
    Mar 22, 2010
    #12
    Searched through Google, found nothing... Will look at that sticky... Thanks anyway v.v

    EDIT:

    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...
     
  13. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #13
    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.
     
  14. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #14
    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
     
  15. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #15
    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?
     
  16. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #16
    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...
     
  17. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #17
    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?
     
  18. macrumors regular

    nickculbertson

    Joined:
    Nov 19, 2010
    Location:
    Nashville, TN
    #18
    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
     
  19. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #19
    Thank you so much! Thanks for helping me... :D

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

    Yes.
     
  20. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #20
    If it is homework you should say so. If you are being paid to do it you should sub-contract it out.
     
  21. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #21
    Yes its homework... o.o
     
  22. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #22
    Well, you should be very thankful that nickculbertson did half your homework for you. :)
     
  23. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #23
    I am. I need to figure out where to put the code :S
     
  24. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #24
    How did you get the "back, forward, refresh, and stop buttons all good and working"? Maybe try the same approach?
     
  25. thread starter macrumors member

    Joined:
    Mar 22, 2010
    #25
    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
     

Share This Page