Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Keeping the actions effects after leaving the view

SDTSDT Posts: 15New Users
Hello guys,
I have an issue, i have an application does have 2 views for example.
The First view with webview , And the second have actions in it and labels connected to the actions.

What happens to me right now is
when someone leave the first view and go to the second and do some actions in it(so the labels.text changes) then he go to the first view , then he goes back to the second, the second view goes back to its default mode

Is there a CODE to insure that the view WOULD NOT go back to its default mode after it had modified from the actions?

by the way:the transition way from the first view to the second is Partial Curl


Thanks
SDT
Post edited by SDT on

Replies

  • Duncan CDuncan C Posts: 8,033Tutorial Authors, Registered Users
    SDT;441190 said:
    Hello guys,
    I have an issue, i have an application does have 2 views for example.
    The First view with webview , And the second have actions in it and labels connected to the actions.

    What happens to me right now is
    when someone leave the first view and go to the second and do some actions in it(so the labels.text changes) then he go to the first view , then he goes back to the second, the second view goes back to its default mode

    Is there a CODE to insure that the view WOULD NOT go back to its default mode after it had modified from the actions?

    by the way:the transition way from the first view to the second is Partial Curl


    Thanks
    SDT
    Views are not a place to store data. They are a place to DISPLAY data.

    Any time you leave a view controller, it's views can get unloaded. In storyboard, the default is to deallocate the whole view controller.

    What you want to do is to create instance variables that store the information that you want to display, and then copy that information to your views in your viewWillAppear method.

    If you are using storyboard and creating a new view controller each time, you need a data container of some sort to hold state information. You can create a data container for each view controller, or you can create a data container singleton that saves state information for your whole app, and put your state data there.
    Regards,

    Duncan C
    WareTo

    mug

    Animated GIF created with Face Dancer, available for free in the app store.
  • SDTSDT Posts: 15New Users
    Duncan C;441206 said:
    Views are not a place to store data. They are a place to DISPLAY data.

    Any time you leave a view controller, it's views can get unloaded. In storyboard, the default is to deallocate the whole view controller.

    What you want to do is to create instance variables that store the information that you want to display, and then copy that information to your views in your viewWillAppear method.

    If you are using storyboard and creating a new view controller each time, you need a data container of some sort to hold state information. You can create a data container for each view controller, or you can create a data container singleton that saves state information for your whole app, and put your state data there.
    Thank you Mr.Duncan C

    now I understand !

    ok

    Can you show me please how to hold state information in a data container

    either for each view or for the whole app?


    Thanks again Sir
  • baja_yubaja_yu Posts: 6,166Super Moderators, Registered Users
    It depends on the data and how it is showed. If you display text in labels you'll need to store those strings, if it's an image, you need to save the image (or remember its filename if it's already saved), if you can reposition elements and you want to restore that, you need to save the positions and sizes of those elements (CGRect).
  • SDTSDT Posts: 15New Users
    Thank you for your interest

    The data that i want it to be displayed the second view is integers to be exact.

    This is the Action I use in the second view
    -(IBAction)calc:(id)sender{            
    int res1 = num1.text.intValue - num2.text.intValue;
    if (res1 <0) {
    eq1.text = [NSString stringWithFormat:@\"%i\", res1];
    }else{
    eq1.text = @\"\"
    }
    }


    I don't know what do you mean when you said
    baja_yu;441229 said:
    It depends on the data and how it is showed. If you display text in labels you'll need to store those strings, if it's an image, you need to save the image (or remember its filename if it's already saved), if you can reposition elements and you want to restore that, you need to save the positions and sizes of those elements (CGRect).
    Can you ِExplain it to me Please
    And if you gave me some links and resources that explain what you meant (and what I need) I will be thankful to you
    Regards
  • baja_yubaja_yu Posts: 6,166Super Moderators, Registered Users
    If you want to store integers, you could use NSUserDefaults for that which is fine for smaller amounts of data.
  • SDTSDT Posts: 15New Users
    baja_yu;441240 said:
    If you want to store integers, you could use NSUserDefaults for that which is fine for smaller amounts of data.

    Ok can you give me an example project with 2 view and action in the second please
    and tell me where did you make changes
    I will be grateful to you sir
  • baja_yubaja_yu Posts: 6,166Super Moderators, Registered Users
    Maybe you should give it a try first, before asking for a complete solution. Just do a quick Google search on "NSUserDefaults".
Sign In or Register to comment.