0

我又遇到了一个超级奇怪的问题。无论是在模拟器上还是在 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

是什么赋予了?

编辑:更奇怪的是,这仅在我单击加载具有我的 UIScrollView 和 UIWebView 的视图控制器的第一个单元格时发生。我单击该webViewDidFinishLoad方法的所有后续单元格都在该方法之前加载viewDidAppear

有什么办法可以纠正这个吗?

4

3 回答 3

2

您应该考虑到模拟器上的数据 Internet 连接比 iPhone 设备上的要好得多。使用同步和多线程时要小心。

于 2011-06-23T13:05:39.960 回答
1

与模拟器相比,您的线程在手机上以不同的顺序执行。这与其说是一个错误,不如说是多线程编程的一个特性。您是在程序中遇到崩溃还是只是对执行顺序感到好奇?

于 2011-06-23T13:09:46.920 回答
0

模拟器在模拟环境中运行 x86 编译代码。难免有些不同。

这就是为什么您应该始终在实际设备上进行测试,而不是完全依赖模拟器来获得测试结果。

于 2011-06-23T13:01:52.767 回答