objective-c – 在segue之后的iOS 5黑屏
发布时间:2020-12-16 10:21:06 所属栏目:百科 来源:网络整理
导读:我有一个带有故事板和两个场景的iOS 5应用程序.场景1是选择列表,而场景2显示每个选择的细节 在场景1中,我需要传递一个变量,我这样做: //Handles the selection -(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSInd
我有一个带有故事板和两个场景的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,它根据需要转换,我只是在屏幕上看不到任何东西. 解决方法
我遇到了一个非常相似的情况.我无意中没有评论这个方法:
-(void)loadView 我相信这种方法会覆盖IB接口,而是通过此代码创建它.检查以确保它被删除或注释掉恕我直言. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |