简体   繁体   中英

Back button seems disabled iOS

In iOs I navigate (pushed) with a navigation controller, and in the viewDidLoad launch a request. This request take might take a long time, and I'd like the users will be able to go back if they won't want wait for the request.

The problem it's that the back button added in the navigation bar seems to be blocked until de request finishes. The button remember the user interaction and when the request finishes go back automatically.

The request has a delegate method for the response and when the app enters on that method the button wake up and go back.

If I touch during a request the touch/click effect don't appear on the button, and it don't either at the end of the request. When I wait until the end, the button had the normal effect for a touched/clicked button.

For that you can enable the button property like this.

 [button setEnable:Yes];
 [button setEnable:Yes];

also use this

 [button setuserintractionEnable:no];

call your request in backgroundthread as

    [self performSelectorInBackground:@selector(startRequest) withObject:nil];

and remember this always for core data too. this is that your UI will be rleased and the request will continue to work in background thread and then implement request cancel on back button

initialize obj as

Obj *obj = [[Obj alloc] initWithDelegate:self selector:@selector(requestFinished)]; [self performSelectorInBackground:@selector(startRequest:) withObject:obj]; obj has the attributes SEL selector, and id delegate;

when request finishes

check if ([obj.delegate respondsToSelector:obj.selctor]) { [obj.delegat performSelector:obj.selector]; }

inform me if you need more specs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM