Flipping between screens

Discussion in 'iOS Development' started by deepp, Mar 14, 2009.

  1. deepp

    deepp New Member

    Joined:
    Sep 4, 2008
    Messages:
    73
    Likes Received:
    0
    Hi everyone i need toknow about my flow of program whether its right or not.Like i have 2 screen A and B,now i need to flip between these 2 screen so what i am doin is that whenevr button in A screen is pressed i am add view of class B as a subview to class A that is

    (void)buttonPressedinClassA: (id)selector
    {
    B * viewcontroller =[ [B alloc]initWithNibName: bunle];
    [self.view addSubview:self.secondScreen.view];


    }

    and similar i am doin when i am in screen B and need to view screen A.

    (void)buttonPressedinClassB: (id)selector
    {
    A * viewcontroller =[ [A alloc]initWithNibName: bunle];
    [self.view addSubview:self.secondScreen.view];


    }

    So want to know can i flip this way between 2 screens? Or will it create a problem?


    Please dont check syntax i have given an example so dont tell me about syntax just please guide me about my flow if its ok?
  2. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    id: selector, what????? sender more like,
  3. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    it doesn't matter what he names that variable thats passed...
  4. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Ok, it's just everyone I've seen was just named sender
  5. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    sender is a good habit to get into only becade of helps you remember that that var is a pointer to whatever triggered the message. Aside from that, you can call that var anything that you want. I simple name a lot of mine param, especially if I don't care what the method iis being passed.
  6. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Back on topic. What you put will look like it's working, but will really be failing, as you're creating a new instance if a view and placing it on top of the current. After multiple button presses, you're left with many of the same two views alternating in a stack. The views will keep stacking up until you run out of memory and the device reboots.
  7. deepp

    deepp New Member

    Joined:
    Sep 4, 2008
    Messages:
    73
    Likes Received:
    0
    Thanks Skylar for help.And yes i did not think of that....Thanks for the help.But then do i need to have three viewController out of which the one will keep controlling and flipping and releasing so there wont be any memory issue?I guess that is the only way to do flipping.Thanks once again...
  8. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I'm pretty sure no one is helping you, or "giving you examples," because Xcode has a template for an app that does just what you want. It's called the "Utility App" template.

    Basically, you need to create a root view controller and have it control the other two view controllers, including doing the actual flipping. If you simply open it up and look at it, you'll see how easy it is to do what you want.
  9. deepp

    deepp New Member

    Joined:
    Sep 4, 2008
    Messages:
    73
    Likes Received:
    0
    No Skylar one person has been helping me consistently and that is you

    Please Register or Log in to view images

    and thanks for all your guidance.And i have been using Metronome example from apples site which is been using flipping but i wanted to know the way i am flipping screen is correct and if i can continue.Thanks a lot for helping me.
  10. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    uhh no offense but i do not think kissing up to him like you're "not-straight" will get him to give you the code. he's right when he says the utility template flips how you want it.

Share This Page