ios推送到navigationController以黑屏结束

时间:2014-02-11 18:34:28

标签: ios iphone objective-c

我尝试通过其在线文档将条带实现到iOS应用程序中。到目前为止一切都很好,现在将paymentView推送到我的导航控制器堆栈上,我得到一个完全坏了的屏幕。认为这是条带视图的问题但是当我没有登录时(参见下面的代码 - 没有给出识别标记)并且正在推送登录屏幕,它也是完全黑的。它不能成为该视图的问题,因为如果我在此视图之前从另一个视图中推送登录视图,它会加载得很好。

那么为什么通过下面的buyButtonAction推送视图会给我黑/搞乱屏幕?! 我已经在这几个小时了......似乎没什么用。

图片:

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

}

电话:

-(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];
    }
}

1 个答案:

答案 0 :(得分:1)

我们可以看到导航栏后面有一个视图。这是iOS 7相关问题。将此行添加到viewDidLoad

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

或者通过将self.stripeView添加到64来更改您的y框架:

CGRectMake(15,84,290,55)



有用的链接:https://stackoverflow.com/a/18103727/1835155