iphone - Scroll position in Text View object on detail view doesn't reset when returning -


i have information in master view uses uitableview object , detail viewcontrailer comes after push user selection it.

my challenge scrolling in uitextview object, doesn't go top of scrolling area on detail view.

the user chooses detail object list in master view controller, , brings in detail viewcontroller. scrolls within uitextview object - dogscrollinginfotextview- on view, going farther down upper lines don't show anymore. return master view controller, , selects different row. upon returning detail view, new object's uitextview object (dogscrollinginfotextview) still positioned previous view left it.

the object being passed uitextview in detailviewcontroller, looks in master view controller

  self.detailviewcontroller.dogscrollinginfo = dog.whatmakesdogspecial; 

in original class definition, property declared this

@property (strong, nonatomic) nsstring *whatmakesdogspecial;

the object used transfer within detailview controller class view declared this

 @property (strong, nonatomic) nsstring *dogscrollinginfo;  @property (weak, nonatomic) iboutlet uitextview *dogscrollinginfotextview; 

and in detailviewcontroller implementation transfer looks this

 self.dogscrollinginfotextview.text = [self.dogscrollinginfo description]; 

i'm not sure if should attach screen shots ? should put in other code? (i have put 2 methods below, 1 each view controller class)

i can't find related scrolling in uitextview class or uiview class, tells me have programatically. seems may have interfacebuilder. i'm using xib's not storyboards. can't find choices in different inspectors change behavior.

is configureview, use in detail view controller class, perhaps not right method use this? think found example using configureview method in xcode master-detail project template, though built application single view project template. , if not, how figure out method use?

i'm trying learn work apple documentation solve challenges this, find hard navigating it. pointers how use documentation better appreciated.

.... code snip master view controller class...

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {      if (!self.detailviewcontroller) {         self.detailviewcontroller = [[hardlyworkingdogsdetailviewcontroller alloc]                                      initwithnibname:@"hardlyworkingdogsdetailviewcontroller"                                      bundle:nil ];      }     nslog(@"the user selected dog @array position %d", indexpath.row);      dog *dog = self.sorteddogdictionaryarray[indexpath.row];       self.detailviewcontroller.dogname= dog.dogname;      self.detailviewcontroller.doglicense = dog.licensestring;      self.detailviewcontroller.dogscrollinginfo = dog.whatmakesdogspecial;      self.detailviewcontroller.dogphoto = dog.dogphoto;       [self.navigationcontroller pushviewcontroller:self.detailviewcontroller animated:yes];     } 

.... code snip detail view controller class...

-(void)configureview {     //nslog(@"configureview # 1 in detail vu");     if (self.doglicense) {          self.doglicenseuilabel.text = [self.doglicense description];         self.dognameuitext.text = [self.dogname description];           self.dogscrollinginfotextview.text = [self.dogscrollinginfo description];          self.dogphotouiimage.image = self.dogphoto;       } } 

thank laurel

since reusing hardlyworkingdogsdetailviewcontroller, behavior makes sense. if hardlyworkingdogsdetailviewcontroller light weight enough, there isn't need reuse it. reinstantiating everytime should fix problem:

self.detailviewcontroller = [[hardlyworkingdogsdetailviewcontroller alloc] initwithnibname:@"hardlyworkingdogsdetailviewcontroller" bundle:nil ];  dog *dog = self.sorteddogdictionaryarray[indexpath.row];  self.detailviewcontroller.dogname= dog.dogname; self.detailviewcontroller.doglicense = dog.licensestring; self.detailviewcontroller.dogscrollinginfo = dog.whatmakesdogspecial; self.detailviewcontroller.dogphoto = dog.dogphoto;  [self.navigationcontroller pushviewcontroller:self.detailviewcontroller animated:yes]; 

although, having not seen other logic, can't won't introduce other bugs if of code depends on self.detailviewcontroller being created once (keeping reference elsewhere, example). if case, or don't want change masterviewcontroller code, can simple put following in hardlyworkingdogsdetailviewcontroller:

-(void)viewwillappear:(bool)animated {      [super viewwillappear:animated];      [self.dogscrollinginfotextview setcontentoffset:cgpointmake(0, 0) animated:no]; } 

this makes every time view appear on screen, scroll view set top. (viewdidload, viewwillappear:, viewdidappear:, viewwilldisappear:, viewdiddisappear: part of uiviewcontroller lifecycle , useful. should read on them)

on side note, uitextview implemented using uiscrollview, scrolling method uiscrollview has, uitextview can well. more info here


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -