gpt4 book ai didi

ios - 如果取消 SKStoreProductViewController 弹出窗口,屏幕会变白

转载 作者:行者123 更新时间:2023-11-29 01:23:25 24 4
gpt4 key购买 nike

跟进此线程 targeting specific app with iOS in app purchase ,所有启动都很好,我看到了目标应用程序,但是当我按下“取消”(因为这是沙盒中唯一真正的选择)时,屏幕变白并且不会返回到上一个屏幕。我尝试过解雇ViewController,但没有运气。

如有任何帮助,我们将不胜感激。

#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>

@interface RLDetailsViewControllerINV : UIViewController <SKStoreProductViewControllerDelegate, UITabBarDelegate> {
}

@property (strong, nonatomic) IBOutlet UIButton *purchaseItemText;
@property (strong, nonatomic) IBOutlet UITextView *textView;

- (void) purchased;

- (IBAction)PurchaseItem:(id)sender;
@property(nonatomic, strong) IBOutlet UITextView *textField;
@end



#import "RLDetailsViewControllerINV.h"
@interface RLDetailsViewControllerINV ()
@end

@implementation RLDetailsViewControllerINV
@synthesize textField;



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


- (void)viewDidLoad {
[super viewDidLoad];
_textView.text = @"Support Sea of Change\n\n100% of proceeds goes to conservation";
[_purchaseItemText setTitle:@"Purchase" forState:UIControlStateNormal];


// Invertebrates
self.textField.text = @"Sea of Change presents the wonderful world of invertebrates\n\n\nThis app is the most comprehensive app on the market with all maters invertebrates, making this perfect for divers and snorkelers alike, to assist them with all of their identification needs.\n\nAlong with Vertebrates (also included in the bundle), these apps cover a whopping 1,670 species, with 2,225 professional photographs.\n\nCorals (317 species)\n- Hard corals\n- Soft corals\n- Sea anemones\n- Hydroids\n- Sea fans\n- Sponges\n- Zoas\n\nCepholopods (14 species)\n- Octopuses\n- Cuttlefish\n\nGastropods (173 species)\n- Nudibranches\n- Sea slugs (non nudibranch tribe)\n- Flat worms\n- Snails & Sea hares\n\nPlus crustaceans, annelids and echinoderms.\n\n\nThere are 559 different species in this app that are all documented and professionally photographed (738+ photos) making this the most comprehensive app on the market for identifying and classifying all invertebrate species.\n";

// \n creates a new line

NSMutableAttributedString *attString=[[NSMutableAttributedString alloc] initWithString:textField.text];
//
// UIFont *font_regular=[UIFont fontWithName:@"HelveticaNeue" size:14.0f];

UIFont *font=[UIFont fontWithName:@"HelveticaNeue" size:14.0f];
UIFont *font_bold=[UIFont fontWithName:@"HelveticaNeue-Bold" size:15.0f];
UIFont *font_boldLarge=[UIFont fontWithName:@"HelveticaNeue-Bold" size:17.0f];

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init] ;
[paragraphStyle setAlignment:NSTextAlignmentCenter];


// the below sets the special format. First number is which letter to start, and second number indicates how many letters are effected.

[attString addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, 925)];
[attString addAttribute:NSFontAttributeName value:font_boldLarge range:NSMakeRange(0, 60)];
[attString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, 60)];
[attString addAttribute:NSFontAttributeName value:font_bold range:NSMakeRange(390, 6)];
[attString addAttribute:NSFontAttributeName value:font_bold range:NSMakeRange(494, 11)];
[attString addAttribute:NSFontAttributeName value:font_bold range:NSMakeRange(545, 10)];
[attString addAttribute:NSFontAttributeName value:font_bold range:NSMakeRange(660, 11)];
[attString addAttribute:NSFontAttributeName value:font_bold range:NSMakeRange(673, 8)];
[attString addAttribute:NSFontAttributeName value:font_bold range:NSMakeRange(686, 11)];

[self.textField setAttributedText:attString];

}

-(void)viewDidAppear:(BOOL)animated{
// this makes the UITextView iniate on top of view, not middle or bottom
// [self.textField scrollRangeToVisible:NSMakeRange(0, 0)];
[self.textField setContentOffset:CGPointMake(0.0, 0.0) animated:NO];
}


- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (IBAction)close:(id)sender {
[self dismissViewControllerAnimated:YES completion:NULL];
}


- (IBAction)PurchaseItem:(id)sender {

SKStoreProductViewController *productVC = [[SKStoreProductViewController alloc] init];
productVC.delegate = self;

NSDictionary *productParameters = @{ SKStoreProductParameterITunesItemIdentifier: @"1015807490" };
[productVC loadProductWithParameters:productParameters completionBlock:^(BOOL result, NSError *error) {
if (error) {
// sad face :(
_textView.text = @"Sorry\n\nBut your transaction failed. ";

}

if (result) {
[self presentViewController:productVC animated:NO completion:nil];
[self purchased];
}
}];
}

- (void) purchased {

_textView.text = @"Thank you for supporting the Sea of Change foundation";
_purchaseItemText.enabled = NO;
[_purchaseItemText setTitle:@"Purchased" forState:UIControlStateDisabled];
}

-(IBAction)popBackOne:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}

@end

最佳答案

好的,找到了。我添加了以下 void 语句来关闭 VC

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)productVC
{
if (productVC)
{ [self dismissViewControllerAnimated:YES completion:nil]; }
}

关于ios - 如果取消 SKStoreProductViewController 弹出窗口,屏幕会变白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34328854/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com