【问题标题】:iOS 5 Black screen after segue转场后 iOS 5 黑屏
【发布时间】:2012-02-15 05:56:37
【问题描述】:

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

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

//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(细节)中,我使用它来验证是否收到了正确的变量

// 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)中没有显示任何内容。所以我知道我有正确的转场,它会根据需要转换,我只是在屏幕上看不到任何东西。

【问题讨论】:

    标签: objective-c ios5 ios-simulator


    【解决方案1】:

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

    -(void)loadView
    

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

    【讨论】:

    • 你一定是在开玩笑吧。这是正确的答案。伙计,我讨厌小东西怎么上来咬你!感谢您的帮助。
    • 这只是......糟糕。我正在学习 ios,这简直要了我的命。我正准备删除该项目并重新开始。非常感谢。
    • 这适用于我的一个场景,但不适用于另一个场景。无论如何,谢谢!
    • 顺便说一句,这是修复第二个问题的原因:stackoverflow.com/a/20502769/1533054
    猜你喜欢
    • 1970-01-01
    • 2014-09-19
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多