저는 뷰가 호출 될 때마다 IOS app 뷰에 대해 2 개의 UITextFeild와 1 UIButton을 프로그래밍 방식으로 생성했습니다. UIButton은 함수 (메소드) 로그인을 호출합니다. 두 UITextViews를 구별 할 수있는 방법을 만들 수 있습니까? 나는 JS 프로그래머이다. 같은 생각 패턴에서 나온 일부는 이드에 의해 객체를 얻는 방법 일까? 또는 모든 UITextFeilds이처럼 분할받을 : 사전에같은 클래스의 여러 객체를 처리하는 방법은 무엇입니까?
-(void)login{
Array *UITF[UITFself.view.UITextFeilds];
UITF[0].text;
}
감사
가장 쉬운 것은 헤더의UITextField
의를 선언하는 것입니다
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