ios - I need to send a message to a method every time my app comes back from background -


i'm developing ios app latest sdk.

it's fullscreen app.

i have method on viewwillappear method has called every time apps comes background.

- (void) viewwillappear:(bool)animated {     [super viewwillappear:animated];      [self setupvideo]; } 

on setupvideo set avcapturevideopreviewlayer because lose video when apps come background.

as have read, viewwillappear isn't called when apps come background , now, don't know put code.

on question, occulus suggest use [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(domylayoutstuff:) name:uiapplicationdidchangestatusbarframenotification object:nil]; doesn't work me.

- (void)viewdidload {     [super viewdidload];     [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(setupvideo:) name:uiapplicationdidchangestatusbarframenotification object:nil]; } 

any advice?

observe uiapplicationwillenterforegroundnotification instead.

- (void)viewdidappear {     [super viewdidappear];     [[nsnotificationcenter defaultcenter] addobserver:self                selector:@selector(enterforeground:)                name:uiapplicationwillenterforegroundnotification                object:nil];     // ... }  - (void)enterforeground:(nsnotification *)notification {     // stuff } 

don't call viewwillappear: directly enterforeground: method. instead move required code separate method , call both viewwillappear: , enterforeground:.


Comments