2011-07-21 26 views
2

我試圖做到以下幾點:如何顯示「加載」釦子AlertView在執行REST請求

  1. 顯示出「正在加載」消息
  2. 一個釦子UIAlertView中執行像一個REST請求

     
    currentPlans = [RestUtils restSynchnonousCall:url 
               usingMethod:@"GET" 
               withBody:nil];

  3. 駁回UIAlertView中

  4. return currentPlans

我看了dispatch_async模式,我也看了這個線程UIAlertView starts to show, screen dims, but it doesn't pop up until it's too late!不理解這麼多... :(

預先感謝您!

回答

3

警報視圖應該通知用戶可以取消或要求簡單的事情,如是/否。對於加載/連接,我建議使用UIActivityIndicator。請注意,更改標準組件的行爲不符合人機界面指南。用戶應該能夠關閉他/她希望的警報視圖。

0

伊萬我認爲你需要使用活動指標進行「加載」過程。 但是,如果你喜歡用按鍵較少alertview然後,使用此代碼: UIAlertView中* loadingAlert = [[UIAlertView中頁頭] initWithTitle:@ 「正在加載......」 消息:無 代表:無 cancelButtonTitle:無 otherButtonTitles :零];

 [loadingAlert show]; 
     [loadingAlert release]; 

當曾經您的請求完成....寫這樣的代碼在該委託方法: [loadingAlert dismissWithClickedButtonIndex:0動畫:YES]; 此代碼自動終止您的alertview。 ** loadingAlert必須在.h文件中定義。