简体   繁体   English

后退按钮似乎已禁用iOS

[英]Back button seems disabled iOS

In iOs I navigate (pushed) with a navigation controller, and in the viewDidLoad launch a request. 在iOs中,我使用导航控制器导航(推送),并在viewDidLoad中启动请求。 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. 问题是导致栏中添加的后退按钮似乎被阻止,直到de请求完成。 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 这是您的UI将被释放,请求将继续在后台线程中工作,然后在后退按钮上实现请求取消

initialize obj as 将obj初始化为

Obj *obj = [[Obj alloc] initWithDelegate:self selector:@selector(requestFinished)]; Obj * obj = [[Obj alloc] initWithDelegate:self selector:@selector(requestFinished)]; [self performSelectorInBackground:@selector(startRequest:) withObject:obj]; [self performSelectorInBackground:@selector(startRequest :) withObject:obj]; obj has the attributes SEL selector, and id delegate; obj具有SEL选择器和id委托的属性;

when request finishes 请求完成时

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

inform me if you need more specs 如果您需要更多规格,请告知我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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