【发布时间】:2025-11-20 16:35:01
【问题描述】:
我尝试通过其在线文档在 iOS 应用中实现条带化。到目前为止一切都很好,现在将 paymentView 推送到我的导航控制器堆栈上,我得到了一个完全破碎的屏幕。以为条纹视图有问题,但是当我没有登录时(请参见下面的代码 - 没有给出标识令牌)并且正在推送登录屏幕,它也完全是黑色的。该视图不会有问题,因为如果我在此视图之前从另一个视图推送登录视图,它会加载得很好。
那么为什么通过下面的 buyButtonAction 推送视图给我黑屏/搞砸了屏幕?! 我已经做了几个小时了.. 似乎没有任何效果。
一张照片:
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];
}
}
【问题讨论】:
标签: ios iphone objective-c