2014-05-17 4 views
0

상단에 테이블이 있고 하단에 텍스트 필드가있는보기가 있습니다. 같은 종류의 채팅. 사용자가 TextField에 무엇인가 입력하고 보내기 버튼 (스크린 샷에 표시되지 않음)을 누르면 표가 해당 항목으로 업데이트됩니다.상단에 테이블이 있고 하단에 텍스트 필드가있는보기에 TextField가 표시되지 않습니다.

enter image description here

질문

내 문제는 내가 TextField로 클릭하면 키보드가 표시하지만 TextField이 보이지 않는 것입니다. 아래 스크린 샷과 같습니다. 나는 두 개의 뷰 만들고있어 방법

enter image description here

은 다음과 같습니다

@my_table = rmq(self.view).append(UITableView, :top_style).get 
@bottom = rmq(self.view).append(UIView, :bottom_style).get 
@bottom = rmq(:bottom_style) 
@send = @bottom.append(UITextField, :send).get 

스타일 시트

def top_style(st) 
    st.frame = {t: 0, l: 0, w: screen_width, h: screen_height - 100} 
    st.background_color = color.white 
    end 

    def bottom_style(st) 
    st.frame = {t: screen_height-100, l: 0, w: screen_width, h: screen_height} 
    st.background_color = color.battleship_gray 
    end 

    def send(st) 
    st.frame = {l: 3, t: 5, w: 220, h: 30} 
    st.background_color = color.white 
    st.view.font = font.small 
    st.layer.cornerRadius = 5 
    st.view.placeholder = "say something..." 
    end 

업데이 트를

RMQ 로그에서 출력

─── UIView 282653120 {l: 0, t: 64, w: 320, h: 504} 
    ├─── UITableView (top_style) 264785408 {l: 0, t: 0, w: 320, h: 468} 
    │ ├─── UITableViewWrapperView 282624240 {l: 0, t: 0, w: 320, h: 468} 
    │ │ ├─── NotesCell (note_cell) 282682640 {l: 0, t: 60, w: 320, h: 30} 
    │ │ │ ├─── UITableViewCellScrollV 282585904 {l: 0, t: 0, w: 320, h: 30} 
    │ │ │ │ ├─── UITableViewCellContent 282688128 {l: 0, t: 0, w: 320, h: 30} 
    │ │ │ │ │ ├─── UILabel (cell_label) 282583168 {l: 15, t: 0, w: 290, h: 30} 
    │ │ ├─── NotesCell (note_cell) 282696944 {l: 0, t: 30, w: 320, h: 30} 
    │ │ │ ├─── UITableViewCellScrollV 282690432 {l: 0, t: 0, w: 320, h: 30} 
    │ │ │ │ ├─── UITableViewCellContent 282617184 {l: 0, t: 0, w: 320, h: 30} 
    │ │ │ │ │ ├─── UILabel (cell_label) 282578944 {l: 15, t: 0, w: 290, h: 30} 
    │ │ ├─── NotesCell (note_cell) 282671168 {l: 0, t: 0, w: 320, h: 30} 
    │ │ │ ├─── UITableViewCellScrollV 282723568 {l: 0, t: 0, w: 320, h: 30} 
    │ │ │ │ ├─── UITableViewCellContent 282709936 {l: 0, t: 0, w: 320, h: 30} 
    │ │ │ │ │ ├─── UILabel (cell_label) 282653440 {l: 15, t: 0, w: 290, h: 30} 
    │ ├─── UIImageView 282715328 {l: 316.5, t: 461, w: 3.5, h: 7} 
    │ ├─── UIImageView 282714752 {l: 313, t: 464.5, w: 7, h: 3.5} 
    ├─── UIView (bottom_style) 282440352 {l: 0, t: 468, w: 320, h: 568} 
    │ ├─── UITextField (send) 282618928 {l: 3, t: 5, w: 220, h: 30} 
    │ │ ├─── UITextFieldLabel 282587568 {l: 0, t: 0, w: 220, h: 29} 
+0

왜 아래 표를 보냅니 까? – Anthony

답변

0

어디에서보기를 만들었습니까? 사용자 정의 내부 UITableViewCell? 그렇다면 layoutSubviews 메서드에서 super을 호출하지 않아야하며 시스템 제목보기 및 하위보기가 만들어지지 않습니다.

는 예를 들어 여기를 참조하십시오 : https://github.com/MohawkApps/aloft/blob/master/app/views/wind_cell.rb#L18

편집이 ... 꽤 이전 질문을 이해하지 못했다.

키보드가 보이거나 숨겨져있을 때 수동으로 하단보기의 위치를 ​​변경해야하는 것처럼 보입니다. 다음과 같이 시도하십시오.

def create_stuff 
    @my_table = rmq(self.view).append(UITableView, :top_style).get 
    @bottom = rmq(self.view).append(UIView, :bottom_style).get 
    @bottom = rmq(:bottom_style) 
    @send = @bottom.append(UITextField, :send).get 
    @send.get.delegate = self # This is crucial for the rest to work 
end 

def textFieldDidBeginEditing(textField) 
    rmq(@bottom).animate(
    duration: 0.3, 
    animations: lambda{|q| 
     q.move top: keyboard_height # Animate it somewhere 
    } 
) 
end 

def textFieldDidEndEditing(textField) 
    rmq(@bottom).animate(
    duration: 0.3, 
    animations: lambda{|q| 
     q.move top: -keyboard_height # Animate it somewhere 
    } 
) 
end 

그 라인에있는 것이 작동해야합니다.

+0

두보기 (테이블보기 및 uiview)는 별도의 UIView에서 만들어집니다. 그래서 그들은 둘 다 우산'UIView'에 속합니다. 나는'rmq.log : tree'의 출력으로 질문을 갱신했습니다. 게시 한 예를 살펴 보겠습니다. 감사합니다 – Anthony

+0

나는 또한이 문제를 해결할 수 있는지 확실하지 않지만이 문제가 발생했습니다. http://stackoverflow.com/questions/1247113/iphone-keyboard-covers-uitextfield – Anthony