Resolved How to use IBAction (Button Press) in ViewDidLoad/ViewWillAppear?

Discussion in 'iOS Programming' started by Terenc3, Mar 19, 2012.

  1. Terenc3, Mar 19, 2012
    Last edited: Mar 22, 2012

    Terenc3 macrumors member

    Joined:
    Jul 15, 2010
    #1
    Hi and thanks for reading. :D

    I want to automate this part of my code:

    Whenever a view loads, I will need to click a button (IBAction for Loading Data From NSUserDefaults) inorder for all saved data to be displayed.

    However, I wish for this to happen without me clicking and all will appear automatically once view appears.

    I reckon it will be good to use ViewDidLoad or ViewWillAppear (By putting an IBAction command in it). I am not entirely sure how to implement this.

    Anybody can help me? :p
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    How much do you know about just calling a method in general?
     
  3. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #3
    Why have a button after all when it's automatic? ;o
    You need to know what methods are, how to call them (which is actually really really easy basics of the development).
    Just put your code from the button in a method, call that wherever you want it to be (the method), and you should be on your way, don't really see the issue here.
     
  4. Terenc3 thread starter macrumors member

    Joined:
    Jul 15, 2010
    #4
    Yea.. Thing is that, I had no programming background at all and my project are all meshes learnt from the web :p.. Hence, I really have no idea how :(. Meanwhile, I am still googling around though.. Thanks for your replies anyways! :D

    P.S: How do I automate load function without the button then? :confused:
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    In that case, I'm gonna suggest you step away from the real coding and spend some time learning the fundamentals of Objective-C / iOS programming. Knowing the basics is only going to help you in the long-run. Patching together code snippets from the internet is not a sound approach, IMHO, to developing a well-written application.
     
  6. Doug-Baker macrumors newbie

    Joined:
    Mar 20, 2012
    #6
    Check out Apple's iOS tutorials

    Hi Terenc3,

    I'm just getting going with iOS programming myself, and I've done what you have -- hunt the web, plus buy some books. In my case, I was trying to look for good Master - Detail / UINavigationController tutorials, and I kept coming up disappointed.

    It was only after I went back and poked around developer.apple.com that I found the "Your Second iOS App: Storyboards," which dealt exactly with the UINavigationController and using Master-Detail views. And what I've found is that this Apple was much better than what I managed to find through Google or my books.

    So my recommendation is to go to the Apple developer site and see what they have there.
     
  7. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #7
    I suggest reading through some books, you don't need to be the best coder in the world all out of a sudden, but basics are nice, or you will keep hitting yourslef in the head alot afterwards.. Heck, every couple of months when I look at my code I feel the same like before, feel sad and have learned alot.

    So just check out the basics and then head back for more questions :)
     

Share This Page