好吧,所以我目前正在試圖讓幾個UITextFields獲得「標籤」在我的代碼性質,她是:在Objective-C中分配標籤屬性?
- (IBAction)userDoneEditing:(id)sender
{
_userFirstNameEntry = UserFirstName.text;
_userLastNameEntry = UserLastName.text;
_emailEntry = UserEmail.text;
_userEntry = UserUser.text;
_userPasswordEntry = UserPassword.text;
UserFirstName.tag = 1;
UserLastName.tag = 2;
UserEmail.tag = 3;
UserUser.tag = 4;
UserPassword.tag = 5;
if(UserFirstName.tag == 1)
{
NSLog(@"textField *UserFirstName did end editing");
}
else if(UserLastName.tag == 2)
{
NSLog(@"textField *UserLastName did end editing");
}
else if(UserEmail.tag == 3)
{
NSLog(@"textField *UserEmail did end editing");
}
else if(UserUser.tag == 4)
{
NSLog(@"textField *UserUser did end editing");
}
else if(UserPassword.tag == 5)
{
NSLog(@"textField *UserPassword did end editing");
}
[sender resignFirstResponder];
}
我用故事板,我也已經設置內部標記屬性故事板文件使用屬性檢查器,但目前在我的邏輯if語句甚至沒有工作..我只是簡單地試圖設置5個UITextFields具有標籤屬性,我做錯了什麼?
非常感謝你的建議,我沒有做的「textField.tag」到「變(實例變量).tag「,並且我確實連接了IBOutlets,即參考變量。但是,我會說,這是非常不必要的,我應該完全使用發件人。 – Chisx