我在 Xcode 5.1.1 中开发了一个应用程序,目标是 iOS 7。我最近升级到 Xcode 6 并清理了所有内容以确保功能。唯一没有完全正常工作的是登录后的 segue 触发器,它现在正在闪烁我试图跳过的 View 的屏幕。这是一个已知的问题?我该如何解决?它在 Xcode 5.1.1 中运行良好。
用文字概括一下,我有一个登录屏幕,该屏幕连接到导航 Controller 。 Nav Controller 中的第一个 View Controller 是仪表板,第二个是欢迎屏幕。他们登录后,我正在加载导航 Controller ,但会跳过仪表板并神奇地自动转到欢迎屏幕。此转场在仪表板转场代码 View 中执行(见下文)。
- (void)viewWillAppear:(BOOL)animated
{
if (self.pushToHomePage)
{
[SVProgressHUD showWithStatus:@"Loading..."];
self.pushToHomePage = NO;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:NO forKey:@"WelcomeCached"];
[defaults setObject:nil forKey:@"WelcomeItems"];
[defaults setObject:nil forKey:@"WelcomeSliders"];
[defaults setObject:nil forKey:@"WelcomeEvents"];
[self performSegueWithIdentifier:@"HomePageSegue" sender:self];
}
else if (self.pushToTradeSignals)
{
[SVProgressHUD showWithStatus:@"Loading..."];
self.pushToTradeSignals = NO;
[self performSegueWithIdentifier:@"TradeSignalsSegue" sender:self];
}
else
{
[super viewWillAppear:animated];
PFUser *user = [PFUser currentUser];
self.lblName.text = [user objectForKey:@"name"];
PFFile *imgProf = [user objectForKey:@"ProfilePic"];
[self.imgProfile setImageWithURL:[NSURL URLWithString:imgProf.url]
placeholderImage:[UIImage imageNamed:@"default_user_icon.png"]];
NSArray *parts = [self.lblName.text componentsSeparatedByString:@" "];
if (parts != nil && parts.count > 1)
[self.lblName boldSubstring:parts[1]];
for (NSIndexPath *indexPath in self.tableView.indexPathsForVisibleRows)
{
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[self setCellColor:[UIColor clearColor] ForCell:cell];
}
[self.navigationController.toolbar setBarTintColor:[UIColor whiteColor]];
[self.navigationController.toolbar setBackgroundColor:[UIColor whiteColor]];
[self.navigationController.toolbar setTintColor:[UIColor darkGrayColor]];
[self.navigationController.toolbar setTranslucent:NO];
[self.navigationController.toolbar setBackgroundImage:[UIImage new]
forToolbarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
[self.navigationController.toolbar setShadowImage:[UIImage new]
forToolbarPosition:UIToolbarPositionAny];
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.navigationController setToolbarHidden:NO animated:YES];
}
}
最佳答案
这里有两个问题。
- 你总是需要调用
[super viewWillAppear:animated:]
。省略此调用会导致未定义的行为。 - 您不得在另一个屏幕转换正在进行时展示新屏幕。这也会导致未定义的行为。 IE。不要在
viewWillAppear
或viewWillDisappear
中显示另一个屏幕。
您应该创建同时设置两个 View Controller 的 UINavigationController
。
关于ios - xcode 6 升级导致 prepare for segue lag showing screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26133989/