作者Piceman (派斯麵)
看板MacDev
標題[問題] 關於UITextView: 橫掃和文字捲動能並存嗎?
時間Fri Oct 1 20:38:30 2010
我正在寫一個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
1F:→ zonble:要不要改用 UIGestureRecognizer 哩? 10/02 03:38
2F:→ zonble:用新的 API,可以讓人生變得光明許多…。 10/02 03:39
3F:→ Piceman:謝謝提示,看google結果,在uitetview上好像還是無解.. 10/02 13:13
4F:→ Piceman:我等會會用程式測試可不可行 10/02 13:14
5F:→ Piceman:不過昨天有想出一個workaround, 在畫面左右放一個view來 10/02 13:14
6F:→ Piceman:偵測。有點了解電子書為何在畫面左右放按鈕切換頁面而非 10/02 13:15
7F:→ Piceman:使用swipe方式了 10/02 13:15
8F:→ Piceman:感謝Zonble大,改api後就可以用了! 10/03 07:40