mgreschke
mgreschke

Reputation: 189

ios pushing to navigationController ends in black screen

I tried to implement stripe into an iOS app through its online documentation. Everything good so far, now pushing the paymentView onto my navigation controller stack I get a completely broken screen. Thought it'd be a problem with the stripe view but when I do not log in (see code below - no identification token given) and the login screen is being pushed instead, it is completely black too. It cant be a problem with that view cause it loads just fine if I push the login view from another view before this one.

So why does pushing view via the buyButtonAction below give me black / fucked up screens?! Ive been on this for hours.. nothing seems to work.

A pic:

ios stripe view

the important code part:

@interface PaymentViewController ()

@end

@implementation PaymentViewController

@synthesize stripeCard = _stripeCard;
@synthesize stripeView;
@synthesize passedProductId;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{


    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.stripeView = [[STPView alloc] initWithFrame:CGRectMake(15,20,290,55)
                                              andKey:@"pk_test_45mqixOu8N9S4lQ6cdn1OXBD"];
    self.stripeView.delegate = self;
    [self.view addSubview:self.stripeView];

}

And the call:

-(void)buyButtonAction:(id)sender
{
    tokenClass *tokenObject = [tokenClass getInstance];
    NSLog(@"%@", tokenObject.token);
    if (tokenObject.token == nil) {
        LoginController *loginController = [[LoginController alloc] init];
        [self.navigationController pushViewController:loginController animated:YES];
    } else {
        NSLog(@"%@", tokenObject.token);
        CGPoint hitPoint = [sender convertPoint:CGPointZero toView:self.tableView];
        NSIndexPath *hitIndex = [self.tableView indexPathForRowAtPoint:hitPoint];
        PaymentViewController *payView = [[PaymentViewController alloc] init];
        payView.passedProductId = [[self.productData valueForKey:@"id"] objectAtIndex:hitIndex.row];
        NSLog(@"passing %@", payView.passedProductId);
        // push payment view
        payView.navigationItem.title = @"One-Click-Payment";
        [self.navigationController pushViewController:payView animated:YES];
    }
}

Upvotes: 0

Views: 1127

Answers (1)

jbouaziz
jbouaziz

Reputation: 1493

We can see that there's a view behind the navigation bar. It's an iOS 7 related issue. Add this line to your viewDidLoad:

 if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;

Or change your self.stripeView frame by adding 64 to y:

CGRectMake(15,84,290,55)



Useful link: https://stackoverflow.com/a/18103727/1835155

Upvotes: 1

Related Questions