2011-08-23 3 views
1

apple의 이메일 앱에서 보낸 전자 메일보기와 같은 텍스트 보내기보기를 원합니다. (기본 iPhone emailapp).이메일 응용 프로그램 텍스트 스타일을 다시 작성하는 방법은 무엇입니까?

2 개의 TextField와 1 개의 TextView로 UIScrollView를 시도했지만 좋지 않은 것 같습니다. scrollview에 아무런 기능이없고 TextView에 텍스트를 입력하면보기가 스크롤되지 않습니다. 텍스트는 세 번째 줄에 숨어 있습니다. 내가 입력 ... 여기

는 사진입니다 : http://s3.imgimg.de/uploads/Bildschirmfoto20110823um1156940f792556940f791456940f79png.png

그것은 다음과 같아야합니다 : http://a5.mzstatic.com/us/r1000/032/Purple/ea/4f/03/mzl.bxracfen.320x480-75.jpg

어떻게 다시

답변

1

당신의 UITextField 내부의 텍스트를 쓰기 시작할 때 단점을 스크롤하려면 다음을 사용 : 완전히 볼 수 있도록하기 위해 당신이 당신의 텍스트 뷰를 편집

또한
[yourScrollView scrollRectToVisible:CGRectMake(yourTextfield.frame.origin.x,yourTextField.frame.origin.y,yourScrollView.frame.size.width,yourScrollView.frame.size.height) animated:YES];  

는, (즉 textViewDidBeginEditing의 방법), 그 프레임을 작게 만들. 그런 다음 텍스트 편집 (예 : textViewDidEndEditing 메소드)을 완료하면 프레임을 원래대로 설정합니다.

편집 : 편집이 완료되면

//add this in .h file 
    NSInteger originalHeight; 

//in .m file 
- (void) textViewDidBeginEditing:(UITextView *)textView 
{ 
     [yourScrollView scrollRectToVisible:CGRectMake(yourTextView.frame.origin.x,yourTextView.frame.origin.y,yourScrollView.frame.size.width,yourScrollView.frame.size.height) animated:YES]; 

     //now set the frame 
     //you just need to change the height, rest can be kept whatever they are 
     //set the newHeight so as to make the textview visible 

     originalHeight = yourTextView.frame.size.height; 
     yourTextView.frame = CGRectMake(x,y,width,newHeight); 

     //rest of the code 
} 

지금, 그것은 예전으로 높이를 설정합니다.

- (void) textViewDidEndEditing:(UITextView *)textView 
{ 
     yourTextView.frame = CGRectMake(x,y,width,originalHeight); 
} 
+0

이 코드를 추가 하시겠습니까? 첫 번째 ScrollDown- 메서드를 추가 할 위치는 어디입니까? – Kovu

+0

수정 된 답변보기 – mayuur

관련 문제