在segue之后的iOS 5黑屏

时间:2012-01-20 17:18:29

标签: objective-c ios5 ios-simulator

我有一个带有故事板和两个场景的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)。所以我知道我有正确的segue,它会根据需要进行转换,我在屏幕上看不到任何内容。

1 个答案:

答案 0 :(得分:12)

我遇到了一个非常相似的情况。我无意中没有评论这个方法:

-(void)loadView

相信此方法会覆盖IB接口,而是通过此代码创建它。检查以确保将其删除或注释掉恕我直言。

相关问题