我又有了一个超级奇怪的问题。无论是在模拟器上还是在iPhone上运行应用程序,我都会得到不同的输出。
请参阅这些控制台日志:
iPhone第一次运行,第一个职业单元格单击
2011-06-23 14:47:28.974 Acando[2033:307] 1 - loadView method running
2011-06-23 14:47:29.156 Acando[2033:307] 2 - viewDidLoad method running
2011-06-23 14:47:29.159 Acando[2033:307] 3 - viewWillAppear method running
[Switching to process 12803 thread 0x0]
[Switching to process 11523 thread 0x0]
2011-06-23 14:47:29.689 Acando[2033:307] 4 - viewDidAppear method running
2011-06-23 14:47:29.692 Acando[2033:307] View: UILabel, height: 21.000000
2011-06-23 14:47:29.695 Acando[2033:307] View: UIWebView, height: 400.000000
2011-06-23 14:47:29.851 Acando[2033:307] webViewDidFinishLoad method running
2011-06-23 14:47:29.855 Acando[2033:307] UIWebView dynamic height: 1150.000000
[Switching to process 12547 thread 0x0]
模拟器首次运行,第一个职业单元格单击
2011-06-23 14:46:26.405 Acando[92098:207] 1 - loadView method running
2011-06-23 14:46:26.421 Acando[92098:207] 2 - viewDidLoad method running
2011-06-23 14:46:26.422 Acando[92098:207] 3 - viewWillAppear method running
[Switching to process 92098 thread 0x2003]
[Switching to process 92098 thread 0x207]
2011-06-23 14:46:26.484 Acando[92098:207] webViewDidFinishLoad method running
2011-06-23 14:46:26.485 Acando[92098:207] UIWebView dynamic height: 1150.000000
[Switching to process 92098 thread 0x6703]
2011-06-23 14:46:26.781 Acando[92098:207] 4 - viewDidAppear method running
2011-06-23 14:46:26.782 Acando[92098:207] View: UILabel, height: 21.000000
2011-06-23 14:46:26.783 Acando[92098:207] View: UIWebView, height: 1150.000000
在iPhone上,方法webViewDidFinishLoad
似乎是在 viewDidAppear
方法之后加载的。
但是在模拟器中,webViewDidFinishLoad
是在 viewDidAppear
方法之前加载的。
怎么回事?
编辑:,更奇怪的是,只有当我单击加载视图控制器的第一个单元格时,才会发生这种情况,该控件包含了my UIScrollView和UIWebView。我在webViewDidFinishLoad
方法上单击的所有后续单元格都在viewDidAppear
方法之前加载。
一定有什么办法可以纠正这一点吗?
发布于 2011-06-23 05:09:46
您的线程在电话上以不同的顺序执行,而不是在模拟器上执行。与其说这是一个bug,不如说是多线程编程的一个特性。您是程序中的崩溃,还是只是好奇的执行顺序?
发布于 2011-06-23 05:05:39
你应该考虑到数据互联网连接在模拟器上远比在iPhone设备上好得多。在使用同步和多线程时要小心。
发布于 2011-06-23 05:01:52
模拟器在模拟环境中运行x86编译代码。肯定会有一些不同。
这就是为什么您应该始终在实际设备上进行测试,而不是完全依赖模拟器来获得测试结果。
https://stackoverflow.com/questions/6454364
复制相似问题