Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS: keeping property values while switching between UITabBarItem's
    primarykey
    data
    text
    <p>I have a <code>UITabBarController</code> linked to 2 <code>UIViewControllers</code>, and in the "first" <code>UIViewController</code> I have properties whose values I need to be maintained when I switch to the other view controller and back. Instead, the value of those properties is reset every time I switch view controllers. How do I fix that? thanks!</p> <p>EDIT:</p> <p>heres my code in the <code>UIViewController</code> (the scrollview is under everything but the tab bar and a navigation bar I have on top):</p> <p><code>SplitBillViewController.m</code></p> <pre><code>@interface SplitBillViewController () @property (nonatomic) NSMutableArray *defPricesArray; @property (nonatomic) NSMutableArray *defQtyArray; @property (nonatomic) NSMutableArray *defTickArray; @property (nonatomic) NSMutableArray *defPeopleArray; @end @implementation SplitBillViewController - (void)viewDidLoad{ [super viewDidLoad]; } -(NSMutableArray *)defPeopleArray{ if(!_defPeopleArray){ _defPeopleArray=[[NSMutableArray alloc] initWithObjects:@"1", nil]; } return _defPeopleArray; } -(NSMutableArray *)defQtyArray{ if(!_defQtyArray){ _defQtyArray=[[NSMutableArray alloc] initWithObjects:@"1", nil]; } return _defQtyArray; } -(NSMutableArray *)defPricesArray{ if(!_defPricesArray){ _defPricesArray=[[NSMutableArray alloc] initWithObjects:@"0.00", nil]; } return _defPricesArray; } -(NSMutableArray *)defTickArray{ if(!_defTickArray){ _defTickArray = [[NSMutableArray alloc] initWithObjects:[NSNumber numberWithInt:1], nil]; } return _defTickArray; } -(void)viewWillAppear:(BOOL)animated{ n=1; aid=@""; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissTipPercentage)]; [self.view addGestureRecognizer:tap]; if (iPhone5){ self.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"background-568h"]]; } else { self.view.backgroundColor = [UIColor blackColor]; } [self.scrollView addSubview:self.itemTable]; [self.scrollView addSubview:self.totalValue]; [self.scrollView addSubview:self.tip]; [self.scrollView addSubview:self.tipPercentage]; [self.scrollView addSubview:self.addedValue]; [self.scrollView addSubview:self.perPerson]; self.scrollView.alpha=1; if (!iPhone5)[self.scrollView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"ScrollViewBackground"]]]; else [self.scrollView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"ScrollViewBackground-568h"]]]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload