每次調用視圖時,我都以編程方式爲iOS應用程序視圖創建了2個UITextFeild和1個UIButton。 UIButton調用函數(方法)登錄如何創建一個方法來區分兩個UITextViews?我是一個JS程序員有些來自相同的思維模式有沒有辦法通過一個ID獲取對象?或讓所有UITextFeilds喜歡割裂開來:提前如何處理同一類的多個對象?
-(void)login{
Array *UITF[UITFself.view.UITextFeilds];
UITF[0].text;
}
感謝
UITextField *uname = [[UITextField alloc] initWithFrame:CGRectMake(80.0, 100, 150.0, 30.0)];
[uname addTarget:self
action:@selector(textFieldDone:)
forControlEvents:UIControlEventEditingDidEndOnExit];
uname.borderStyle = UITextBorderStyleRoundedRect;
uname.keyboardType = UITextAutocapitalizationTypeNone;
uname.returnKeyType = UIReturnKeyDone;
uname.autocorrectionType = UITextAutocorrectionTypeNo;
[self.view addSubview:uname];
-(void)login {
//send login message
NSString *u=uname.text;//user name text
NSString *p=pass.text;//password text
NSLog(u);
NSLog(p);
}
這裏有一個問題:'UITextView'和'UITextField'是不同的類,'UITextFeild'是拼寫錯誤。 – PengOne