如何编写代码来完成这项工作?

时间:2015-06-22 01:57:26

标签: ios objective-c

我在VC1中使用以下代码:

ResultViewController *primaryView = [[ResultViewController alloc] initWithNibName:@"ResultView" bundle:nil];
UIImageView *profileView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"profile.png"]];
[_coinView setPrimaryView: primaryView.view];
[_coinView setSecondaryView: profileView];
[_coinView setSpinTime:1.0];

比我在视图文件中有以下代码:

-(IBAction) flipTouched:(id)sender{
    [UIView transitionFromView:(displayingPrimary ? self.primaryView : self.secondaryView)
                            toView:(displayingPrimary ? self.secondaryView : self.primaryView)
                          duration: _spinTime
                           options: UIViewAnimationOptionTransitionFlipFromLeft+UIViewAnimationOptionCurveEaseInOut
                        completion:^(BOOL finished) {
                            if (finished) {
                                displayingPrimary = !displayingPrimary;
                             }
         }
    }];
}

这个代码组合帮我翻转VC1中显示的视图,效果很好,但是现在我要做的是在VC1中显示一个按钮,当它点击时,我也可以翻转相同的视图。所以我想功能代码应该用VC1编写,我只是想不出一个好的代码来做,有人可以帮我吗?顺便说一句,我该如何调用" [self loadData]"视图文件中的VC1?

2 个答案:

答案 0 :(得分:0)

听起来您需要将flipTouched:UIButton

联系起来
UIButton *myButton = [[UIButton alloc] init]; // Or an outlet from your XIB/storyboard
[myButton addTarget:self
             action:@selector(flipTouched:)
   forControlEvents:UIControlEventTouchUpInside];

答案 1 :(得分:0)

[_coinView flipTouched: nil ];

我发现这对我有用。