Unk*_*der 3 objective-c ios-simulator ios5
我有一个带有故事板和两个场景的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];
}
}
Run Code Online (Sandbox Code Playgroud)
在场景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];
}
Run Code Online (Sandbox Code Playgroud)
所有这一切都很好,警报框显示正确的变量,并有一个过渡到新场景.但是,警告框总共显示5次以上,一旦完成,整个窗口都是黑色的.此时不显示我的场景(场景2).所以我知道我有正确的segue,它根据需要转换,我只是在屏幕上看不到任何东西.
Pad*_*215 12
我遇到了一个非常相似的情况.我无意中没有评论这个方法:
-(void)loadView
Run Code Online (Sandbox Code Playgroud)
我相信这种方法会覆盖IB接口,而是通过此代码创建它.检查以确保它被删除或注释掉恕我直言.
| 归档时间: |
|
| 查看次数: |
4004 次 |
| 最近记录: |