【发布时间】: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