iswiftapp / iswift

Objective-C to Swift Converter
30 stars 3 forks source link

Cannot Convert Obj-C Interface with Property of Type UINavigationControllerOperation #189

Open andrekandore opened 8 years ago

andrekandore commented 8 years ago

I tried to convert the following code, but the property doesn't carry over into swift unless I change the type to something else such as NSInteger etc...

Code taken from here: https://github.com/Dzamir/OldStyleNavigationControllerAnimatedTransition

#import <UIKit/UIKit.h>

@interface OldStyleNavigationControllerAnimatedTransition : NSObject <UIViewControllerAnimatedTransitioning>

//Cant Convert this Property
@property UINavigationControllerOperation operation;

@end

@implementation OldStyleNavigationControllerAnimatedTransition

- (id)init {
    self = [super init];
    if (self) {
        _operation = UINavigationControllerOperationPush;
    }
    return self;
}

- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext;
{
    return 0.35;
}

- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext;
{
    UIViewController * fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIViewController * toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    CGRect screenFrame = fromViewController.view.frame;
    UIView * containerView = [transitionContext containerView];
    [containerView addSubview:toViewController.view];
    CGFloat toStartX, fromEndX;

    if (_operation == UINavigationControllerOperationPush)
    {
        toStartX = screenFrame.size.width;
        fromEndX = -screenFrame.size.width;
    } else
    {
        toStartX = -screenFrame.size.width;
        fromEndX = screenFrame.size.width;
    }

    toViewController.view.frame = CGRectOffset(toViewController.view.frame, toStartX, 0);
    [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^
    {
        toViewController.view.frame = CGRectOffset(toViewController.view.frame, -toStartX, 0);
        fromViewController.view.frame = CGRectOffset(screenFrame, fromEndX, 0);
    } completion:^(BOOL finished) {
        [fromViewController.view removeFromSuperview];
        [transitionContext completeTransition:YES];
    }];
}

@end
drkameleon commented 8 years ago

Hmm... It must be an Unknown Type error.

I'm putting it into my to-fix list and will do my best to get it fixed by the very next update.

In the meantime, would you mind trying putting @class UINavigationControllerOperation; on top of it? (e.g. after the #import statement). I know it's not a fix, rather a... hack, but it should work.

Please, let me know! :)