2013-08-14 2 views
0

Прежде всего, извиниться за мой английский. Я начинаю разработку iOS, у меня есть приложение, которое имеет 3 viewControllers (MainViewController, CenterViewController и ActionViewController).Невозможно выполнить viewController из UIModalTransitionStylePartialCurl

В первом VC (MainVC) У меня есть кнопка, эта кнопка приведет вас к CenterVC, используя UIModalTransitionStylePartialCurl.

Во втором VC (CenterVC) У меня есть и другая кнопка, которая приведет вас к ActionVC, но вот проблема. Я могу видеть ActionVC, но этот VC представлен ниже MainVC с эффектом Curl.

Я попытался решить, используя этот код внутри на IBAction в CenterVC:

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

Пожалуйста, кто может помочь мне с этой проблемой?

+0

Это может быть поможет вам [самостоятельно presentModalViewController: actionVC анимированные: YES]; – SRI

+0

почему вы не используете навигационный контроллер для этого ....? –

+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]; 
+0

ios4 + UIView Animation Устаревшее сейчас яблоко предлагает использовать Block wise Animation –

+0

Спасибо за ответ Samkit, но Нитин сказал, что этот метод устарел ... какое-то другое решение? –

+0

Где я вставляю этот код? Я запутался ... Я вставляю код внутри кнопки IBAction из CenterVC? Необходимо создать навигационный контроллер? Извините, но я новичок ... большое вам спасибо! –

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 

Спасибо всем, кто мне помог.

Дэвид Альварес Medina

Смежные вопросы