我建立的应用程序称为“KiKi”,它的第一页是“StartView”。应用程序将运行启动视图并检查用户是否已登录。之后,它会将用户重定向到正确的页面。
该应用程序在我的iPhone 6(真实的)上正常运行。但它在启动时总是启动缓慢。启动大约需要2-3秒。 (我的其他应用程序只需要大约1秒钟即可启动)。
最近,我已将该应用程序提交到iTunes Connect,但它仍然停留在“添加新版本”页面。我无法选择任何构建版本,只显示“(处理)”。我已经等了几天但没有改变。我相信这是因为app中的错误。
路径:“StartView” - > “LoginView”(如果用户已注销)或“LoginVerificationView”(如果用户已登录)
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m (我已经隐藏了解析服务的APPLICATION KEYS)
#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
记录(错误日志)
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>.
答案 0 :(得分:1)
您的帖子中有许多事项需要注意
- 警告:正在主线程上执行长时间运行的操作。打破warnBlockingOperationOnMainThread()进行调试。
醇>
这是来自解析的警告,这意味着您必须在此方法中放置断点以实际找出原因。保持断点后,只需查看堆栈跟踪即可找到该方法。您可能希望在后台执行一些解析活动。
一些解析方法用于在后台执行。而不是
[yourParseObject save]
您可以使用
[yourParseObject saveInBackground]
这也可能是您的应用需要时间启动的原因之一。
- 我无法选择任何构建版本,只显示“(处理)”。我已经等了几天但没有任何改变。
醇>
如果您的应用处于处理状态,原因可能是任何原因。最好的选择是通过参考资料和帮助部分的iTunesconnect联系我们页面告诉Apple你的情况。
与此同时,您也可以尝试本post
中提到的内容其他建议:
- 不鼓励在分离的视图控制器上显示视图控制器。开始/结束的不平衡呼叫 外观过渡为。
醇>
原因是你在viewWillAppear上展示了一个viewcontroller。你不应该这样做。您应该直接显示LoginView。而不是StarView。
希望这有帮助。