2011-11-10 5 views
0

Ha誰もが質問をしていますが、どのようにスワイプジェスチャー機能をtableviewに実装できますか?私のプロジェクトには多くの章があり、各章はtableviewセルにロードされています。クリックしてtableviewのフッターに配置し、tableview.everythingのヘッダーの前のページのボタンに移動します。ユーザーがbuttons.Butをタップすると、データをリロードします。ユーザースワイプ右のそれは、次のとprvous章について次の章と万力versa.myコードは、私はちょうどスワイプ機能でそれを実装したいTableviewcellでスワイプする

-(IBAction)_clickbtntablenextchapter:(id)sender 
{ 
    delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] + 1]; 
    [delegate reloadVerses]; 
    [self resetReadViewToVerse:1]; 
} 
-(IBAction)_clickbtntableprvchapter:(id)sender 
{ 
    delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] - 1]; 
    [delegate reloadVerses]; 
    [self resetReadViewToVerse:1]; 
} 

ある負荷にしたいです。ありがとうございます。 編集

-(void) handleSwipeGesture:(UISwipeGestureRecognizer*)recognizer { 
    // do whatever you need to do ... 
    delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] + 1]; 
    [delegate reloadVerses]; 
    [self resetReadViewToVerse:1]; 
} 
-(void) handleSwipeGestureleft:(UISwipeGestureRecognizer*)recognizer { 
    // do whatever you need to do ... 
    delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] - 1]; 
    [delegate reloadVerses]; 
    [self resetReadViewToVerse:1]; 
} 
this is gesture code and my button code is ,in button it works perfect. 
-(IBAction)_clickbtntablenext:(id)sender 
{ 
    delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] + 1]; 
    [delegate reloadVerses]; 
    [self resetReadViewToVerse:1]; 
} 
-(IBAction)_clickbtntableprevious:(id)sender 
{ 
    delegate.selectedChapter = [NSString stringWithFormat:@"%d",[delegate.selectedChapter intValue] - 1]; 
    [delegate reloadVerses]; 
    [self resetReadViewToVerse:1]; 
} 
+0

、uはこのアイデアを持っている場合は、私を助けてください。 Thnks。 – ICoder

+0

http://stackoverflow.com/questions/4279699/how-to-detect-swipe-gesture-in-iphone-sdk試してください – User97693321

+0

@tonyblueサンプルコードはios5でのみ動作します。私は歌います4.3 sir.thanks – ICoder

答えて

4

スワイプ動作は、編集モードでのデフォルトは、あなたがInserting and Deleting Rows in Editing Modeになるはずです。

独自の動作が必要な場合は、UISwipeGestureRecognizerを使用してスワイプを検出できます。

EDIT:

がreconizerを作成します。

UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)]; 
swipeGesture.direction = UISwipeGestureRecognizerDirectionRight // or whatever 
[cell addGestureRecognizer:swipeGesture]; 
[swipeGesture release]; 

ターゲットのためのコールバックを実装します。青haii @tony

-(void) handleSwipeGesture:(UISwipeGestureRecognizer*)recognizer { 
    // do whatever you need to do ... 
} 
+0

ジェスチャー認識ツールのドキュメントを読むhttp://developer.apple.com/library/IOs/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html#//apple_ref/doc/uid/TP40009541-CH6-SW1(add認識バーからのコールバックを取得したときにcellForRowAtIndexPathメソッドでセルを作成すると(セルごとにそのセルを作成したいので)、セルを作成するときに配置します(UIViewサブクラスです)。 – jbat100

+0

セルがスワイプされました(認識装置があなたの細胞であるという見解を持っているので) – jbat100

+1

それは完璧に機能しますが、1つの問題は、それをスワイプすると2倍になります。つまり、1章3章5章7章とviseversa。 – ICoder

関連する問題