1

目前我正在開發一個iPhone應用程序,通過滑動手勢識別器在兩個控件之間導航。如何通過在iPhone SDK中刷卡來推/拉控制器?

應用程序了結構是這樣的enter image description here

爲此,我先裝日曆屏幕並在其上的看法沒有負載,我用PushViewController加載主屏幕。在主屏幕上,如果用戶向左滑動屏幕,則日曆屏幕會顯示使用PopViewController,或者如果用戶滑動右側,則由PushViewController顯示列表視圖屏幕。這工作正常。

現在的問題是,在我的列表視圖屏幕上,我正在使用UITableViewController,其中手勢識別器將無法完美工作,有些時候它無法滑動。

我怎樣才能在這些屏幕之間滑動完美,我想滑動scrollview滾動相同。

請給我提供一些解決方案。

回答

0

長時間谷歌搜索後,我找到了一個解決方案。我正在採用寬度爲3屏幕的滾動視圖,並在其第一個屏幕框架上添加日曆xib視圖,在其第二個屏幕框架上添加主頁xib視圖,然後在其第三個屏幕框架上添加列表xib視圖,使用此我在主屏幕上創建一個UINavigationController *navigationHome; id parentController; 屏幕管理滾動視圖的主屏幕導航,併爲其餘的控制器使用相同的技術,這將使我工作得很好。

4

如果您的應用程序在iOS 3.2或更高版本上,您可以使用UISwipeGestureRecognizer進行如下操作。

//Add Table 
    UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)]; 
    table.dataSource=self; 
    table.delegate=self; 
    [table reloadData]; 
    [self.view addSubview:table]; 
    [table release]; 

    //Add Gesture Recognizer 
    swipeLeftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)]; 
    [table addGestureRecognizer:swipeLeftRecognizer]; 
    [swipeLeftRecognizer release]; 

而在你的控制器的某個地方;

-(void)handleSwipeFrom { 

    if (swipeLeftRecognizer.direction == UISwipeGestureRecognizerDirectionRight) { 

     // Your code here to go back to the main view 

    } 

} 

這隻會對正確的滑動作出反應,並會讓你的錶行爲正常。希望這可以幫助! :)

相關問題