ios - UIButton setTittle not working in a specific case -
i have 2 views in app , plist file store values.
in first view i've created button called frequenciesbutton
opens second view , button restore default values.
in second view there pickerview , "done" button.
on .m of first view:
- (void)viewdidload { [super viewdidload]; // self.gamesettings = [[nsmutabledictionary alloc] initwithcontentsoffile:gamesettingsfilepath]; } -(void)viewwillappear:(bool)animated { [self refreshview]; } - (void)refreshview { [self.frequenciesbutton settitle:[nsstring stringwithformat:@"%@ hz , %@ hz", [self.gamesettings objectforkey:@"freq-freq1"], [self.gamesettings objectforkey:@"freq-freq2"]] forstate:uicontrolstatenormal]; ... } - (ibaction)setdefaultvalues:(uibutton *)sender { [self.gamesettings setvalue:@880 forkey:@"freq-freq1"]; [self.gamesettings setvalue:@1122 forkey:@"freq-freq2"]; ... [self.gamesettings writetofile:gamesettingsfilepath atomically:yes]; [self refreshview]; }
when first view loaded, button title changed default values stored in gamesettings
dictionary. method settitle:
works.
when click on frequenciesbutton
opens second view pickerview, select 2 new values freq-freq1
, freq-freq2
, saves plist file on done button.
the problem frequenciesbutton
title not changed when second view dissmissed , first view appears. refreshview
method called button settitle:
not work.
in case, if go 1 screen, , return view, button title updated.
and when click on defaultvaluesbutton
, frequenciesbutton
title changes. method settitle:
works.
any ideas of must happening?
haha! love added link project.
so!! problem have separate properties in each view hold data saved plist file, self.settings
. fine, don't mesh them together. requirement had this, when switching views, keep ivar or properties updated data updates :d
here how fixed problem:
- (void)viewwillappear:(bool)animated { self.settings = [nsmutabledictionary dictionarywithcontentsoffile: filepath]; [self updateview]; }
i checked out file , updated, dictionary in testviewcontroller.h
not updated
i hope problem :)
Comments
Post a Comment