ios UIWindow 错误使用导致无法接收motionEnded(摇一摇)函数

今天遇到一个问题,第一次运行程序时,

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event

函数无法调用,第二次就好了。找了1天,终于找到了原因。

在第一次运行时,显示了一个帮助页面,而这个页面当时是使用再加一层UIWindow来实现的,现实时调用了

makeKeyAndVisible这个函数,导航结束后,也没有把原始的window设置为key。在ios8上没什么问题,但是在ios9上,原始的window就无法接收motionEnded等摇一摇事件了,但是点击等手势事件没问题。改法就是不用makeKeyAndVisible,仅仅使用sethidden来显示新的UIwindow。

看看什么叫做key window,这个在ios中没有具体说明,在mac里有说明

The Key Window

The key window responds to user input, whether from the keyboard, mouse, or alternative input devices, for an application and is the primary recipient of messages from menus and panels. Usually, a window is made key when the user clicks it. Each application can have only one key window at a given time.

时间: 2024-08-11 05:36:15

ios UIWindow 错误使用导致无法接收motionEnded(摇一摇)函数的相关文章

iOS编译错误:Property cannot have array or function type 'Block' (aka 'void (XXXXView *__st

XXXXView 中的Block错误,原因: typedef void (^Block)(XXXXView *); 在这个demo中忘记写^了,导致此错误 iOS编译错误:Property cannot have array or function type 'Block' (aka 'void (XXXXView *__st

Oracle登录时提示错误,导致用户无法登录

Oracle登录时提示错误,导致用户无法登录,错误如下 ------------------------------------------------------------------------- ORA-00604:递归SQL级别1出现错误 ORA-01653表SYS.AUD$无法通过1024(在表空间SYSTEM中扩展) ORA-02002:写入审计线索时出错 ORA-01653表SYS.AUD$无法通过1024(在表空间SYSTEM中扩展) ---------------------

淘宝开放平台使用WebClient,WebRequest访问时的错误提示导致麻烦

淘宝开放平台(TOP)提供OAuth2.0支持 通过C#的WebClient/WebRequest直接访问时会提示grant type is empty,这是一个非常恼人的错误,你会发现即使传了这个参数提示依然是这样. 使用linux的curl不会有这样的问题. 通过多次排查,对比,将近8小时我才找到问题是Content-Type必须为application/x-www-form-urlencoded. 淘宝开放平台使用WebClient,WebRequest访问时的错误提示导致麻烦

Mysql5.7.11 安装 cacti0.8.8f ,在导入cacti.sql数据库时出现下记错误,导致数据库导入终止: ERROR 1067 (42000) at line 1847: Invalid default value for 'status_fail_date'

解决方法:vim /etc/my.cnf 文件,加入 : sql-mode="NO_ENGINE_SUBSTITUTION" , Systemctl restart mysqld 进入mysql的之后可执行: select @@sql_mode 查询当前使用的sql_mode是什么 Mysql5.7.11 安装 cacti0.8.8f ,在导入cacti.sql数据库时出现下记错误,导致数据库导入终止: ERROR 1067 (42000) at line 1847: Invalid

ios常见错误之 Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? 这是因为给你的StoryBoard没有设置默认显示的controller, 解决方法: from:http://my.oschina.net/u/936286/blog/316565 ios常见错误之 Failed to instanti

iOS 发布错误,ERROR ITMS-9000:"Invalid Code Signing Entitlements.Your application Bundles signature code

iOS 发布错误,ERROR ITMS-9000:"Invalid Code Signing Entitlements.Your application Bundles signature code signing entitlements that are not supported on ios ,Specifically, value'*' for key 'com.apple.developer.associated-domains' in 'Payload/'' is not supp

Xamarin iOS教程之使用按钮接接收用户输入

Xamarin iOS教程之使用按钮接接收用户输入 Xamarin iOS使用按钮接接收用户输入 按钮是用户交互的最基础控件.即使是在iPhone或者iPad中,用户使用最多操作也是通过触摸实现点击.而点击操作最多的控件往往是按钮控件.一般使用UIButton类来实现按钮.本节将主要讲解按钮相关的内容. Xamarin iOS使用代码添加按钮 由于按钮拖放的方式比较简单,所以不再介绍.这里直接讲解代码中如何添加按钮.使用代码为主视图添加一个按钮的方式和在2.2.2节中讲解的步骤是一样的.首先需要

IOS 编译错误,iOS compile error: no visible @interface for 'CDVCommandDelegateImpl' declares the selector

把Cordova 升级到 3.6.3 版本后,在变异的使用出现了如下问题 The error: /Volumes/local.uhmuhm.net/projectxxx/htdocs/phonegap/src/Projectxxx/platforms/ios/Projectxxx/Classes/MainViewController.m:154:19: error: no visible @interface for 'CDVCommandDelegateImpl' declares the s

摇一摇 iOS

//微信的摇一摇是怎么实现的~发现原来 ios本身就支持//在 UIResponder中存在这么一套方法 - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0); - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event __OSX_AV