2013-05-14 18 views
1

我正在使用此代碼來檢測從monotouch.dialog中的入口元素的鍵盤返回。檢測entryelement的鍵盤是否返回monotouch.dialog

RltEntryElement createServerUrlEntry(){ 

     try { 


      ServerNameEntryElement = new EntryElement ("Website url","placeholder", 
     "value"); 


      ServerNameEntryElement .ReturnKeyType = UIReturnKeyType .Done ; 
      ServerNameEntryElement.ShouldReturn += ShouldReturnMethd; 
      return ServerNameEntryElement ; 

     } catch (Exception ex) { 
      RltLog .HandleException (ex); 
      return null ; 
     } 
    } 

public bool ShouldReturnMethd() 
     { 

      RltLog .LogInfo ("Helllllllllllllo"); 
      return false ; 
     } 

它的工作原理和日誌"Helllllllllllllo"後按'完成'。但鍵盤沒有消散。我應該用什麼來正確地工作?

回答

1

就叫「ResignFirstResponder」

public bool ShouldReturnMethd() 
{ 
    RltLog.LogInfo ("Helllllllllllllo"); 
    ServerNameEntryElement.ResignFirstResponder(true); 
    return false; 
} 
0

它不應該是

return true; 

我還沒有在文檔啥模樣,但該方法的名稱表示你可能要返回true

+0

感謝您的回覆。當它返回true時,鍵盤也不會消失。 – 2013-05-15 07:13:09