iphone - Opening a book reader app at the some page where the app was closed -


i have app reading book, , while reading if user hit home button on iphone, , again reopen app , should open on same page in user previously, have got x position page, since book in vertical scrolling. plz let me know implement information.

-(void)scrollviewdidenddecelerating:(uiscrollview *)_scrollview {     cgpoint p = _scrollview.contentoffset;     nslog(@"x = %f",p.x);     appdelegate_iphone *delegate = [[uiapplication sharedapplication] delegate];     delegate.datavalue = p.x; } 

you can use nsuserdefaults save state information.

-(void)scrollviewdidenddecelerating:(uiscrollview *)_scrollview {     cgpoint p = _scrollview.contentoffset;     nslog(@"x = %f",p.x);     appdelegate_iphone *delegate = [[uiapplication sharedapplication] delegate];     delegate.datavalue = p.x;      // save state     nsuserdefaults* ud = [nsuserdefaults standarduserdefaults];     [ud setinteger: p.x forkey @"x-position"];     [ud synchronize]; } 

to retrieve saved state

nsuserdefaults* ud = [nsuserdefaults standarduserdefaults]; int x = [ud integerforkey: @"x-position"]; 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -