2017-05-12 20 views
-1

我需要一些幫助來查找ViewController中的按鈕。 enter image description hereXamarin IOS按鈕ID在哪裏可以找到

正如您在圖像中看到的,Hello World是屏幕上的默認按鈕。但是,我不明白代碼如何連接到該按鈕。 enter image description here 正如我試圖點擊該按鈕,它不顯示任何相關的名稱或身份。我可以知道如何或在哪裏鏈接或調用的按鈕?

+0

添加第一個:不要將您的代碼作爲圖像提供。請複製並在此處過去。第二:ViewController.cs文件旁邊有一個ViewController.designer.cs文件。因爲它是置於故事板內的UI控件,Xamarin會自動爲您引用它。該引用是在* .designer.cs文件中進行的。 –

+0

https://developer.xamarin.com/guides/ios/user_interface/designer/introduction/ – SushiHangover

回答

0

enter image description here

點擊你的故事板的按鈕,打開屬性視圖(View>墊>屬性)。給按鈕一個名字。就是這樣,Xamarin工作室將創建所需的插座。

現在,如果您打開ViewController.designer.cs文件。你可以看到創建的網點。您可以在您的代碼中找到以下代碼ViewController.designer.cs

[Outlet] 
UIKit.UIButton Button { get; set; } 

void ReleaseDesignerOutlets() 
{ 
    if (Button != null) { 
     Button.Dispose(); 
     Button = null; 
    } 
} 
相關問題