我已经用单指Pan Gesture在右侧成功创建了一个面板。当用户使用双指手势滑动时,我必须在同一侧显示另一个视图控制器。我尝试在SWRevealViewController.h类文件中添加它,但它无法正常工作。我创建了两个不同的Seques和sw_right和sw_test ..如果用户滑动一根手指,将显示SW_right seque的视图控制器,如果用户滑动两个手指,则应显示SW_test segue。请帮助我来到这里。下面是我的代码
static NSString * const SWSegueRearIdentifier = @"sw_rear";
static NSString * const SWSegueFrontIdentifier = @"sw_front";
static NSString * const SWSegueRightIdentifier = @"sw_right";
static NSString * const SWSegueRightIdentifier2 =@"sw_test"; // mytest
- (void)prepareForSegue:(SWRevealViewControllerSegue *)segue sender:(id)sender
{
// $ using a custom segue we can get access to the storyboard-loaded rear/front view controllers
// the trick is to define segues of type SWRevealViewControllerSegue on the storyboard
// connecting the SWRevealViewController to the desired front/rear controllers,
// and setting the identifiers to "sw_rear" and "sw_front"
// $ these segues are invoked manually in the loadView method if a storyboard
// was used to instantiate the SWRevealViewController
// $ none of this would be necessary if Apple exposed "relationship" segues for container view controllers.
NSString *identifier = segue.identifier;
if ( [segue isKindOfClass:[SWRevealViewControllerSegue class]] && sender == nil )
{
if ( [identifier isEqualToString:SWSegueRearIdentifier] )
{
segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
{
[self _setRearViewController:dvc animated:NO];
};
}
else if ( [identifier isEqualToString:SWSegueFrontIdentifier] )
{
segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
{
[self _setFrontViewController:dvc animated:NO];
};
}
else if ( [identifier isEqualToString:SWSegueRightIdentifier] )
{
segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
{
[self _setRightViewController:dvc animated:NO];
};
}
//mytest code
**else if ( [identifier isEqualToString:SWSegueRightIdentifier2] )
{
segue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
{
[self _setRightViewController:dvc animated:NO];
};
}**
//code test
}
}
答案 0 :(得分:0)
最后,我有一个解决方案,有两个面板。我只使用一个控制器根据执行的触摸显示两个不同的数据。在这里我做了什么。我在揭密视图控制器中编写了这段代码
-(void)viewWillAppear:(BOOL)animated
{
int numberofTouches = self.revealViewController.panGestureRecognizer.numberOfTouches;
NSLog(@"%d",numberofTouches);
if (numberofTouches ==1) {
numberOfTouchesString=@"One";
}
else if (numberofTouches==2)
{
numberOfTouchesString=@"Two";
}
[learningSearchTableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if ([numberOfTouchesString isEqualToString:@"One"]) {
return 6;
}
else if ([numberOfTouchesString isEqualToString:@"Two"])
{
return 5;
}
else
return 0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"selected");
if ([numberOfTouchesString isEqualToString:@"One"]) {
NSLog(@"%@",indexPath);
}
else if ([numberOfTouchesString isEqualToString:@"Two"])
{
NSLog(@"The other %@",indexPath);
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"learningSearchCellIdentifier";
LearningSearchCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
if ([numberOfTouchesString isEqualToString:@"One"]) {
cell.subjectNameLabel.text=@"ART";
cell.subjecDataAndSessionLabel.text=@"Friday 11th April - LS3(Cohort 11)";
cell.teacherNameLabel.text=@"Mr Starr";
}
else if ([numberOfTouchesString isEqualToString:@"Two"])
{
cell.subjectNameLabel.text=@"English";
cell.subjecDataAndSessionLabel.text=@"Sunday 12th April - LS3(Cohort 11)";
cell.teacherNameLabel.text=@"Mr Harry";
}
return cell;
}