看板 MacDev 關於我們 聯絡資訊
我正在寫一個app 在使用uitextview處理scroll和swipe時碰到一個難題 如果將uitextview的user interact關閉 當內容文字超過視窗時會無法使用捲動方式把下面的文字拉上來 但是把user interact開啟 uitextview會無法偵測手勢 已經有嘗試建立UITextview的subclsss 可是問題依然 當開啟user interact時 subclss中的以下程式碼無法被觸發 SwipableUITextview: UITextview { - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch=[touches anyObject]; NSLog(@"touch begin in Textview: %@", NSStringFromCGPoint([touch locationInView:self])); //以上兩行是用來檢查事件是否有被觸發的程式碼 [super touchesBegan:touches withEvent:event]; [[self nextResponder] touchesBegan:touches withEvent:event]; } 請問有人知道如何讓uitextview可以捲動文字和偵測手勢的方法嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.42.57.84
zonble:要不要改用 UIGestureRecognizer 哩? 10/02 03:38
zonble:用新的 API,可以讓人生變得光明許多…。 10/02 03:39
Piceman:謝謝提示,看google結果,在uitetview上好像還是無解.. 10/02 13:13
Piceman:我等會會用程式測試可不可行 10/02 13:14
Piceman:不過昨天有想出一個workaround, 在畫面左右放一個view來 10/02 13:14
Piceman:偵測。有點了解電子書為何在畫面左右放按鈕切換頁面而非 10/02 13:15
Piceman:使用swipe方式了 10/02 13:15
Piceman:感謝Zonble大,改api後就可以用了! 10/03 07:40