gpt4 book ai didi

ios - 测试时我的 iPhone 上的应用程序启动缓慢

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

我构建的应用程序称为“KiKi”,它的第一页是“StartView”。该应用程序将运行开始 View 并检查用户是否登录。之后,它将用户重定向到正确的页面。

该应用程序在我的 iPhone 6(真机)上运行良好。但启动时总是启动缓慢。启动大约需要 2-3 秒。 (我的其他应用程序启动只需要大约 1 秒)。

最近,我已将应用程序提交到 iTunes Connect,但它卡在“添加新构建版本”页面。我无法选择任何构建版本,它只显示“(处理)”。我已经等了几天了,但什么都没有改变。我认为这是因为应用程序中的错误。

路径:“StartView”-->“LoginView”(如果用户注销)或“LoginVerificationView”(如果用户登录)

AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;


@end

AppDelegate.m(我隐藏了解析服务的应用程序 key )

#import "AppDelegate.h"
#import <Parse/Parse.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

// [Optional] Power your app with Local Datastore. For more info, go to
// https://parse.com/docs/ios_guide#localdatastore/iOS
[Parse enableLocalDatastore];

// Initialize Parse.
[Parse setApplicationId:@"PARSE_KEY1"
clientKey:@"PARSE_KEY2"];

PFInstallation *currentInstallation = [PFInstallation currentInstallation]; [currentInstallation saveInBackground];

// [Optional] Track statistics around application opens.
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [self colorWithHexString:@"000000"]}];
[[UINavigationBar appearance] setBarTintColor:[self colorWithHexString:@"c98b9a"]];
[[UINavigationBar appearance] setTintColor:[self colorWithHexString:@"00ff12"]];

// Override point for customization after application launch.
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

-(UIColor*)colorWithHexString:(NSString*)hex
{
NSString *cString = [[hex stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];

// String should be 6 or 8 characters
if ([cString length] < 6) return [UIColor grayColor];

// strip 0X if it appears
if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2];

if ([cString length] != 6) return [UIColor grayColor];

// Separate into r, g, b substrings
NSRange range;
range.location = 0;
range.length = 2;
NSString *rString = [cString substringWithRange:range];

range.location = 2;
NSString *gString = [cString substringWithRange:range];

range.location = 4;
NSString *bString = [cString substringWithRange:range];

// Scan values
unsigned int r, g, b;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];

return [UIColor colorWithRed:((float) r / 255.0f)
green:((float) g / 255.0f)
blue:((float) b / 255.0f)
alpha:1.0f];
}

@end

StartView.h

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import <ParseUI/ParseUI.h>

@interface StartView : UIViewController

@end

StartView.m

#import "StartView.h"
#import "LoginVerificationView.h"
#import "LoginView.h"

@interface StartView ()

@end

@implementation StartView

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

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
// redirect user to LoginVerificationView
LoginVerificationView *destview = [self.storyboard instantiateViewControllerWithIdentifier:@"SB-LoginVerificationView"];
[self presentViewController:destview animated:NO completion:nil];
} else {
// show the signup or login screen
LoginView *destview = [self.storyboard instantiateViewControllerWithIdentifier:@"SB-LoginView"];
[self presentViewController:destview animated:NO completion:nil];
}
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

Log(错误日志)

    2015-10-26 00:25:46.416 Kiki[3121:97351] Simulator user has requested new graphics quality: 100
2015-10-26 00:25:46.457 Kiki[3121:97351] Warning: A long-running operation is being executed on the main thread.
Break on warnBlockingOperationOnMainThread() to debug.
2015-10-26 00:25:46.741 Kiki[3121:97351] Warning: A long-running operation is being executed on the main thread.
Break on warnBlockingOperationOnMainThread() to debug.
2015-10-26 00:25:48.544 Kiki[3121:97351] Presenting view controllers on detached view controllers is discouraged <StartView: 0x7f8d58f3f830>.
2015-10-26 00:25:48.683 Kiki[3121:97351] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7f8d5a842400>.

最佳答案

你的帖子有很多地方需要注意

  1. Warning: A long-running operation is being executed on the main thread. Break on warnBlockingOperationOnMainThread() to debug.

这是来自 parse 的警告,意味着您必须在此方法中放置一个断点才能真正找出原因。保留断点后,只需查看堆栈跟踪即可找到方法。您可能想在后台执行一些解析事件。

一些解析方法曾经在后台执行。喜欢而不是

[你的 ParseObject 保存]您可以使用 [yourParseObject saveInBackground]

这也可能是您的应用启动时间过长的原因之一。

  1. I can't select any of the build version and it just displaying "(Processing)". I have waited for a few days but nothing changed.

如果您的应用处于处理状态,原因可能是任何原因。最好的选择是您通过资源和帮助部分中的 iTunesconnect 联系我们页面将您的情况告诉 Apple。

与此同时,您还可以尝试此 post 中提到的内容

补充建议:

  1. Presenting view controllers on detached view controllers is discouraged . Unbalanced calls to begin/end appearance transitions for .

这样做的原因是您在 viewWillAppear 上呈现一个 View Controller 。你不应该那样做。您应该直接显示 LoginView 而不是 StarView。

希望这对您有所帮助。

关于ios - 测试时我的 iPhone 上的应用程序启动缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33332141/

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