我的要求是,如果我点击 button1 相应的图像必须通过滑动手势进入下一个视图,因此我将发送者值发送到子视图控制器
viewcontroller.m
-(IBAction)cricket:(id)sender
{
//cricket is a button
NSString *str=[cricket currentTitle];
ChildViewController *child=[[ChildViewController alloc]init];
[child handleSwipe:str];
}
这是
childviewcontroller.m
int imageIndex=4;
- (IBAction)handleSwipe:(UISwipeGestureRecognizer *)sender
{
if([sender isEqual:@"cricket"]))
{
NSArray *images=[[NSArray alloc]initWithObjects:[UIImage imageNamed:@"exterior1.png"], [UIImage imageNamed:@"cricket.png"],[UIImage imageNamed:@"floor_plan1.png"],Nil];
UISwipeGestureRecognizerDirection direction=[(UISwipeGestureRecognizer *)sender direction];
switch (direction) {
case UISwipeGestureRecognizerDirectionLeft:
imageIndex++;
break;
case UISwipeGestureRecognizerDirectionRight:
imageIndex--;
default:
break;
}
imageIndex=(imageIndex<0) ? ([images count]-1):
imageIndex % [images count];
[images objectAtIndex:imageIndex];
}
我对这件事很震惊,请帮助我