iphone - iOS: keeping property values while switching between UITabBarItem's -
i have uitabbarcontroller
linked 2 uiviewcontrollers
, , in "first" uiviewcontroller
have properties values need maintained when switch other view controller , back. instead, value of properties reset every time switch view controllers. how fix that? thanks!
edit:
heres code in uiviewcontroller
(the scrollview under tab bar , navigation bar have on top):
splitbillviewcontroller.m
@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"]]]; }
Comments
Post a Comment