[UIWindow setRootViewController:]需要4.0以上支持

问题描述:今天Touch Team出Stupid测试版,安装20多台iPhone、iTouch、iPad,都可以安装。但是有一台iPhone(3.1.2)报错,不能安装。注:其他设备基本都在4.0以上。

问题分析:因为是调试安装,所以能看到报错信息,如下:

GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".tty /dev/ttys000
target remote-mobile /tmp/.XcodeGDBRemote-16799-38
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 11779 thread 0x0]
[Switching to process 11779 thread 0x0]
sharedlibrary apply-load-rules all
warning: Unable to read symbols for /Library/MobileSubstrate/MobileSubstrate.dylib (file not found).
warning: Unable to read symbols for /Library/Frameworks/CydiaSubstrate.framework/Libraries/SubstrateLoader.dylib (file not found).
2011-09-27 17:40:14.990 FSStupid[2874:207] MS:Notice: Installing: com.flipscript.stupid [FSStupid] (478.52)
2011-09-27 17:40:15.368 FSStupid[2874:207] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/Backgrounder.dylib
warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/Backgrounder.dylib (file not found).
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.1.3/Symbols/usr/lib/libsubstrate.dylib (file not found).
2011-09-27 17:40:17.131 FSStupid[2874:207] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/Multitasking.dylib
warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/Multitasking.dylib (file not found).
2011-09-27 17:40:18.007 FSStupid[2874:207] *** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x23fe20
2011-09-27 17:40:18.016 FSStupid[2874:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x23fe20'
2011-09-27 17:40:18.034 FSStupid[2874:207] Stack: (
843263261,
825818644,
843267069,
842763033,
842725440,
11685,
843742792,
843741800,
844074496,
844072508,
844071060,
860907492,
843011371,
843009055,
843738120,
843731504,
11481,
11404
)
terminate called after throwing an instance of 'NSException'
(gdb)

 

报错的语句是:

self.window.rootViewController = startViewController;

仔细查看报错信息,发现这句报错:-[UIWindow setRootViewController:]: unrecognized selector sent to instance。查看setRootViewController方法,发现需要4.0以上支持。

解决方案:把出错代码:

self.window.rootViewController = startViewController;

替换为:

if( [[[UIDevice currentDevice] systemVersion] compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending )
[self.window addSubview:self.mainViewController.view];
else self.window.rootViewController = self.mainViewController;

一切ok了。

后台运行App导致无法调试

问题描述:Touch Team做Stupid,调试的时候console报以下问题:
warning: Unable to read symbols for /Library/MobileSubstrate/MobileSubstrate.dylib (file not found). warning: Unable to read symbols for /Library/Frameworks/CydiaSubstrate.framework/Libraries/SubstrateLoader.dylib (file not found). 2011-09-21 12:46:54.465 FSStupid[18953:607] MS:Notice: Installing: com.flipscript.stupid [FSStupid] (550.58) 2011-09-21 12:46:54.489 FSStupid[18953:607] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/Activator.dylib warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/Activator.dylib (file not found). 2011-09-21 12:46:54.752 FSStupid[18953:607] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/QQInput.dylib warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/QQInput.dylib (file not found). warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J3)/Symbols/usr/lib/libsubstrate.dylib (file not found). 2011-09-21 12:46:54.889 FSStupid[18953:607] MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib warning: Unable to read symbols for /Library/MobileSubstrate/DynamicLibraries/libstatusbar.dylib (file not found).

问题分析:用其他的几台设备测试,一切正常。用有问题的那台机器,然后直接运行,也一切正常。网上查了下,是一些后台运行的程序可能搞鬼(如报错信息中的:QQInput.dylib、libstatusbar.dylib等)

问题解决:用Cydia删除一些dylib,就没有问题了。

程序员的1927年12月31日午夜一秒谜案

虽说是程序员问的,不过内容和编程本身其实并没什么太大关系,请各位听我细细道来。StackOverflow是一个程序员向的问答网站,广大程序员们在上面交流经验、提问答疑,三天前,一位名叫Freewind的用户发布了下面这个问题:

我在用Java编写一段比较两个字符串时间间隔的程序,然而当我比较“1927-12-31 23:54:07”和“1927-12-31 23:54:08”这两个时间时,输出结果却不是1……而是353。

当我把两个时间分别往后调整1秒,变成“1927-12-31 23:54:08”和“1927-12-31 23:54:09”,结果就又是1了!——可为什么那两个时间的结果,却是353呢?

面对这一诡异的问题,网友们很快追问,“你的区域(Locale)设置是什么?这可能是个区域问题/和当地夏令时之类的东西有关。”

楼主很快附上了Java版本号和区域设置:

sun.util.calendar.ZoneInfo[id="Asia/Shanghai",
offset=28800000,dstSavings=0,
useDaylight=false,
transitions=19,
lastRule=null]

(……没错,Freewind君,似乎是一位魔都死程。不知道这里有没有人认识这位老兄?)

在这份追加信息出现仅仅两分钟之后,StackOverflow站上的问答狂人Jon Skeet给出了如下答复——

这是因为上海的时区在12月31日发生了变化。

请看这里。(网页截图如下)

(1928年1月1日0点0分,当地时间由地方平时(Local Mean Time)改为北京时间/中国标准时间)

简单地说,在1927年末的最后那一个午夜,时钟被往回拨了5分52秒。所以“1927-12-31 23:54:08”这一秒,事实上,发生了两次,而看起来在计算当地时间时,Java将其视为了后面那一个时间点,于是就产生了这一差别。

这正是时区世界的奇妙与不可思议啊。

在StackFlow网民们纷纷膜拜Jon Skeet的神速之时,其他程序员也以测试的方式验证了这一结果的正确——美国时间木有这个问题。看来,当一枚程序员,有时真的需要上通天文、下知地理啊……

HTML5 APP

PhoneGap is an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores. PhoneGap leverages web technologies developers already know best... HTML and JavaScript.

http://www.phonegap.com/

 

Sencha Touch, a high-performance HTML5 mobile application framework, is the cornerstone of the Sencha HTML5 platform. Built for enabling world-class user experiences, Sencha Touch is the only framework that enables developers to build fast and impressive apps that work on iOS, Android, BlackBerry, Kindle Fire, and more.

http://www.sencha.com/products/touch/

 

 

jQuery Mobile, A unified, HTML5-based user interface system for all popular mobile device platforms, built on the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design.

jQuery Mobile

iPhone 接近传感器 无响应

问题描述:今天施佳音做FSStupid,一个益智类iPhone游戏,需要做接近传感器检测。在单独的例子里是可以运行,但是把同样代码加入到项目中接近传感器没有响应。

问题分析:仔细查找并论证,发现接近传感器只能在竖向的时候工作。

问题解决:把应用程序切换到竖向显示,一切OK了。

AIR在Mac和PC平台下路径问题

问题描述:前些日子Vision部在给Timberland做年会用的年度报表应用软件。因为需要用在Mac和PC平台,所以使用AIR平台开发。因为一直在PC中开发,所以PC一切正常,但是到了Mac中就回报错。

问题分析:那天正好是Adobe Suite CS5.5发布会,回来后加了个通宵,帮Cailven解决这个bug。因为报错是报的类库中,一直在类库中找寻解决办法。搞了一个晚上,突然发现AIR返回的path不一样。

问题解决
把如下代码:
var path : String = file.nativePath;
改写为:
var path : String = file.url;
一切OK了。

总结:file.nativePat对于Mac是不适用的,请使用file.url代替。这也许是AIR的bug。

Excel Library

最近公司里在做Timberland的一个内部使用的数据分析软件,AIR的,需要读excel,找了点读xlsx的类库,最后选择Rxlsx。一个是比较新,一个是支持office2007格式。

老外写的类库:http://code.google.com/p/as3xls/

国人写的类库:http://code.google.com/p/rxlsx/