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
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];
}
}
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];
}
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…