无法从UIModalTransitionStylePartialCurl执行viewController

时间:2013-08-14 07:39:17

标签: ios objective-c

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

在第一个VC(MainVC)中,我有一个按钮,此按钮会使用UIModalTransitionStylePartialCurl将您带到CenterVC。

在第二个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:^{}];
     }];
}

拜托,有人可以帮我解决这个问题吗?

2 个答案:

答案 0 :(得分: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];

答案 1 :(得分:0)

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

mainVC.h:

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

@interface OXDmainViewController : UIViewController <OXDcurlViewControllerDelegate>

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

- (IBAction)curlReveal:(id)sender;

@end

mainVC.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

感谢所有帮助过我的人。

DavidÁlvarezMedina