i have nsmutabledictionary in mainviewcontroller loads text detailviewcontroller. want user able add text , save changes nsmutabledictionary when detailviewcontroller show again changes show up. have researched part can find can done in uitextfield. use uitextview in case user wants add lot of text longer uitextfield field. possible do?
nsmutabledictionary in mainviewcontroller;
this isn't working , i'm not sure how proceed. difficult find tutorial/examples of this.code:`detailviewcontroller *detailview = [[detailviewcontroller alloc] initwithnibname:@"detailviewcontroller" bundle:nil]; if ((int)index == 0) { nsmutabledictionary *adictionary = [nsmutabledictionary dictionarywithobjectsandkeys: @"some existing text", @"textkey", nil]; detailview.adictionary = adictionary; }` , code load in detailviewcontroller; self.thetext.text =[(nsmutabledictionary *)adictionary objectforkey:@"textkey"]; have right navigationbarbutton want hide keyboard , save text nsmutabledictionary @ same time when touched. `-(void)doneediting:(id)sender { [(nsmutabledictionary *)adictionary writetofile:@"textkey"]; [thetext resignfirstresponder]; } }`
how start, doneediting not proper delegate call uitextfield. uitextfield reference, read on information , lookup uitextfielddelegate. i'll give hint, -textfielddidendediting.
why needing cast nsmutabledictionary. it's hard tell looks it's out of scope. potential problem.
why writing dictionary file, i'm guessing want replace value , not write file. again why need cast.code:self.thetext.text =[(nsmutabledictionary *)adictionary objectforkey:@"textkey"];
replace this.code:[(nsmutabledictionary *)adictionary writetofile:@"textkey"]; [thetext resignfirstresponder];
code:[adictionary setvalue:[self thetext].text forkey:@"textkey"]; [thetext resignfirstresponder];
yes, can resize uitextfield depending on size of text. text property of uitextfield nsstring, nsstring has instance methods give metrics of string. can put constraints depending on needs.
hope helps.
edit: believe size instance methods available uikit. have verify.
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless

No comments:
Post a Comment