segue之后的iOS 5黑屏 [英] iOS 5 Black screen after segue

查看:89
本文介绍了segue之后的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)。所以我知道我有正确的segue,它按照需要转换,我在屏幕上看不到任何东西。

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

i 相信此方法会覆盖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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆