2014-02-28 2 views
0

나는, 프로그램 적 UITextField을 만들어 (나는 스토리 보드를 사용하지 않음)이 코드 ViewControllersubview로 추가 ...프로그램 생성 할 수 없습니다의 UITextField 편집 (아이폰 OS)는

@interface ViewController() 
@property (nonatomic, strong) UITextField *searchLocationBar; 
@end 

@synthesize searchLocationBar; 

... 그러나

self.searchLocationBar = [[UITextField alloc] init]; 
self.searchLocationBar.frame = CGRectMake(0.0f, 0.0f, 320.0f, 40.0f); 
self.searchLocationBar.delegate = self; 
self.searchLocationBar.borderStyle = UITextBorderStyleRoundedRect; 
self.searchLocationBar.placeholder = @"a temporary placeholder"; 
self.searchLocationBar.userInteractionEnabled = YES; 
self.searchLocationBar.clearButtonMode = UITextFieldViewModeAlways; 
[self.view addSubview:self.searchLocationBar]; 

, 나는이 강한 게 아니 할 수 없습니다 어떤 텍스트라도 - textfield을 탭하면 아무 일도 일어나지 않습니다. 다른보기와 중복되지 않습니다. 내가 UITextfield not editable-iphone 확인했습니다

하지만 초보자와 나는 단순히 뭔가를 그리워 완전히 확신 아무런 영향

- 제발 조언을. 감사합니다.

편집 : 한 가지 더 : 나는 Google지도 GMSMapView의이 self.view = mapView_로 self.view을 할당; Google API 문서에 설명 된대로 몇 가지 테스트를 한 후이 선언을 통해 모든 컨트롤이 완벽하게 작동하지만 텍스트 필드는 작동하지 않는다는 것을 알게되었습니다. 나는 많은 것을 다시 쓸 필요가 있기 때문에 맵뷰를 어떤 서브뷰로 옮기고 싶지 않다.

누군가 제안을 추가 할 수 있습니까?

+0

self.searchLocationBar.font = [UIFont fontWithName : "돋움 - 굵게"크기 @ : 25]; 확인해 봐 ? – Rushabh

+1

'textFieldShouldBeginEditing :'textfield delegate 메소드에서'NO'를 리턴합니까? – Amar

+0

이 줄을 주석으로 작성하십시오 self.searchLocationBar.delegate = self; 그리고 그것의 작동 여부를 확인하십시오. – Rushabh

답변

1

추가 잊지 :

[self.view bringSubviewToFront:self.searchLocationBar]; 
1

Xcode 5에서 코드가 작동해야합니다. Xcode 버전을 확인하는 것이 좋습니다. Xcode 버전의 코드에 문제가있을 수 있습니다. 다음 방법으로 시도 할 수 있습니다.

UITextField *lastName = [[[UITextField alloc] initWithFrame:CGRectMake(10, 100, 300, 30)]; 
[self.view addSubview:lastName]; 

lastName.placeholder = @"Enter your last name here"; //for place holder 
lastName.textAlignment = UITextAlignmentLeft;   //for text Alignment 
lastName.font = [UIFont fontWithName:@"MarkerFelt-Thin" size:14.0]; // text font 
lastName.adjustsFontSizeToFitWidth = YES;  //adjust the font size to fit width. 

lastName.textColor = [UIColor greenColor];    //text color 
lastName.keyboardType = UIKeyboardTypeAlphabet;  //keyboard type of ur choice 
lastName.returnKeyType = UIReturnKeyDone;    //returnKey type for keyboard 
lastName.clearButtonMode = UITextFieldViewModeWhileEditing;//for clear button on right side 

lastName.delegate = self;    //use this when ur using Delegate methods of UITextField 

는 많은 다른 속성을 사용할 수 있습니다 그러나 이들은 유 싶어 더 속성과 방법들을 다음 링크를 참조 사용하는 방법에 대해 알고 frequently.if 우리가 사용하는 몇 가지 있습니다. 또한 UITextField에 대한 속성을 만들 수 있습니다. 어느 쪽이든 Xcode에서 제대로 작동해야합니다.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextField_Class/Reference/UITextField.html