嗨:)
我正在開發一個iPhone應用程序,該應用程序應該從Web加載XML頁面並使用它進行操作。問題是應用程序在下載頁面時會凍結,而且看起來很醜。
我想展示某種「加載,請」帶旋轉輪的信息...
什麼是正確的方法?
我試圖用一個NSThread
,但我收到此錯誤:
Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread.
這是我使用加載XML頁面的OBJ-C代碼:
「正在加載」彈出菜單/進度條
NSString* xmlUrl = [NSString stringWithFormat:@"http://urltothexmlpage"];
NSString* XML = [NSString stringWithContentsOfURL:[NSURL URLWithString:xmlUrl]
encoding:NSUTF8StringEncoding
error:nil];