转场后 iOS 5 黑屏

时间:2023-03-25
本文介绍了转场后 iOS 5 黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个带有情节提要和两个场景的 iOS 5 应用程序.场景 1 是一个选择列表,而场景 2 显示每个选择的详细信息

I have an iOS 5 application with a storyboard and two scenes. Scene 1 is a selection list while Scene 2 shows details for each selection

在场景 1 中,我需要传递一个变量,我这样做:

In Scene 1 I need to pass a variable and I do that with:

//Handles the selection 
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
    Guests *myGuests =[guestList objectAtIndex:[indexPath row]];

    selectedGuest = [[NSString alloc] initWithFormat:@"You have selected %@", myGuests.guestID];

    [self performSegueWithIdentifier:@"TGG" sender:self];
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([[segue identifier] isEqualToString:@"TGG"]){
        GuestDetailsViewController *vc = [segue destinationViewController];
        [vc setGuestSelected:selectedGuest];
    }
}

在场景 2(细节)中,我使用它来验证是否收到了正确的变量

In Scene 2 (details) I use this to verify that the right variable was received like this

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    NSString *msg = [[NSString alloc] initWithFormat:@"You have selected %@", guestSelected];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Selection" message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];          

     nameCell.textLabel.text= msg;

    [super viewDidLoad];
}

所有这些都可以正常工作,并且警告框会显示正确的变量,并且会过渡到新场景.但是,警告框总共显示 5 次以上 &结束,一旦完成,整个窗口都是黑色的.那时我的场景(场景 2)中没有显示任何内容.所以我知道我有正确的转场,它会根据需要转换,我只是在屏幕上看不到任何东西.

All of this works fine and the alert box shows the right variable and there is a transition to the new scene. HOWEVER, the alert box displays a total of 5 times over & over and, once completed, the whole window is black. Nothing from my scene (Scene 2) is displayed at that point. So I know I have the right segue, it transitions as desired, I just can't see anything on my screen.

推荐答案

我遇到了非常相似的情况.我无意中取消了该方法的注释:

i ran into a situation very similar. i had unintentionally un-commented the method:

-(void)loadView

相信这个方法覆盖了 IB 接口,而是用这个代码创建了它.检查以确保它被删除或注释掉恕我直言.

i believe this method overrides the IB interface and created it from this code instead. check to make sure it is either removed or commented out IMHO.

这篇关于转场后 iOS 5 黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:应用程序窗口应该在应用程序启动结束时有一个根视图控制器 - 即使所有已知问题都已修复 下一篇:.xib 文件和 .storyboard 有什么区别?

相关文章