从背景恢复后,应用程序屏幕变为全黑

时间:2016-03-22 11:50:28

标签: ios objective-c xcode swift

相同的回复:https://github.com/tush4r/Phone

我有一个小测试应用程序没有特殊功能,除了一些视图元素,包括字段,按钮等。它是一个单独的故事板模块,在加载应用程序时会被调用。

这里的一切似乎都很好,直到我按下主页按钮在后台推送应用程序。以下是相同的屏幕截图:一个在应用程序运行时,一个在后台进入并返回到前台。

我不知道为什么会这样?在视图控制器中实现的一些事情是:当输入的数字格式不正确时,键盘隐藏,UIButton,UITextField和几个警报。

Screenshot when the App is running for the first time Screenshot when app came back to the foreground

非常感谢任何帮助。 谢谢!

Xcode 7.3
Swift 2.2
iPhone 6s iOS 9.3

1 个答案:

答案 0 :(得分:1)

尝试使用definePresentationContext设置true,对我有类似的问题。 在 class PostLogin extends AsyncTask<Void, Void, String> { @Override protected String doInBackground(Void... params) { String response = null; Uri.Builder builder= new Uri.Builder().appendQueryParameter("username","amit").appendQueryParameter("password", "amit"); String parm=builder.build().getEncodedQuery(); try { response = postData("your url here/",parm); }catch (Exception e) { e.printStackTrace(); } Log.d("test", "response string is:" + response); return response; } } private String postData(String path, String param)throws IOException { StringBuffer response = null; URL url = new URL(path); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setDoOutput(true); // connection.setRequestProperty("Content-Type", "application/json"); // connection.setRequestProperty("Accept", "application/json"); OutputStream out = connection.getOutputStream(); out.write(param.getBytes()); out.flush(); out.close(); int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; response = new StringBuffer(); while ((line = br.readLine()) != null) { response.append(line); } br.close(); } return response.toString(); } 中,添加viewDidLoad()