0

首先,为我的英语道歉。我是 iOS 开发的初学者,我正在做一个有 3 个viewControllers(MainViewController、CenterViewController 和 ActionViewController)的应用程序。

在第一个 VC ( MainVC) 中,我有一个按钮,该按钮使用UIModalTransitionStylePartialCurl.

在第二个 VC ( CenterVC) 中,我有另一个按钮可以将您带到ActionVC,但这里有一个问题。我可以看到,ActionVC但是这个 VC 在下面MainVC显示了卷曲效果。

我试图在 CenterVC 的 IBAction 中使用此代码来解决:

- (IBAction)actionReveal:(id)sender {
     [self dismissViewControllerAnimated:YES completion:^{
     ActionViewController *actionVC = [[ActionViewController      alloc]initWithNibName:@"ActionViewController" bundle:nil];
          [self presentViewController:actionVC animated:YES completion:^{}];
     }];
}

拜托,谁能帮我解决这个问题?

4

2 回答 2

0

我已经解决了这个问题。在这里写下解决方案,以防有人遇到同样的问题。

主VC.h:

#import <UIKit/UIKit.h>
#import "OXDcurlViewController.h"

@interface OXDmainViewController : UIViewController <OXDcurlViewControllerDelegate>

@property (strong, nonatomic) IBOutlet UIButton *curlButton;

- (IBAction)curlReveal:(id)sender;

@end

主VC.m:

#import "OXDmainViewController.h"
#import "OXDcurlViewController.h"
#import "OXDsecondViewController.h"

@interface OXDmainViewController ()

@end

@implementation OXDmainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)curlReveal:(id)sender {
    OXDcurlViewController *curlVC = [[OXDcurlViewController          alloc]initWithNibName:@"OXDcurlViewController" bundle:nil];
    curlVC.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    curlVC.delegate = self;
    [self presentViewController:curlVC animated:YES completion:^{}];
}

-(void)presentSecondVC{
    OXDsecondViewController *secondVC = [[OXDsecondViewController     alloc]initWithNibName:@"OXDsecondViewController" bundle:nil];
    secondVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:secondVC animated:YES completion:^{}];

}



@end

curlVC.h:

#import <UIKit/UIKit.h>

@protocol OXDcurlViewControllerDelegate <NSObject>

@optional
-(void)presentSecondVC;

@end


@interface OXDcurlViewController : UIViewController

@property (strong, nonatomic) IBOutlet UIButton *actionButton;
@property (nonatomic, weak) id<OXDcurlViewControllerDelegate> delegate;

- (IBAction)actionReveal:(id)sender;


@end

curlVC.m:

#import "OXDcurlViewController.h"
#import "OXDsecondViewController.h"

@interface OXDcurlViewController ()
@end

@implementation OXDcurlViewController
@synthesize delegate;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)actionReveal:(id)sender {
    [self dismissViewControllerAnimated:YES completion:^{
        [self.delegate presentSecondVC];
    }];

}


@end

感谢所有帮助过我的人。

大卫阿尔瓦雷斯麦地那

于 2013-08-19T06:37:29.303 回答
0

尝试使用导航控制器使用它:

    [UIView beginAnimations:@"animation" context:nil];
    //put this instance to navigation controller
    [self.navigationController pushViewController: detailController animated:NO];
    // Animate the navigation controller
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
    // Set animation time
    [UIView setAnimationDelay:0.01];
    [UIView setAnimationDuration:0.3];
    // Commit animation
    [UIView commitAnimations];
于 2013-08-14T07:55:07.043 回答