問題描述
我有一個帶有情節提要和兩個場景的 iOS 5 應用程序.場景 1 是一個選擇列表,而場景 2 顯示每個選擇的詳細信息
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
在場景 1 中,我需要傳遞一個變量,我這樣做:
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];
}
}
在場景 2(細節)中,我使用它來驗證是否收到了正確的變量
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];
}
所有這些都可以正常工作,并且警告框會顯示正確的變量,并且會過渡到新場景.但是,警告框總共顯示 5 次以上 &結束,一旦完成,整個窗口都是黑色的.那時我的場景(場景 2)中沒有顯示任何內容.所以我知道我有正確的轉場,它會根據需要轉換,我只是在屏幕上看不到任何東西.
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.
推薦答案
我遇到了非常相似的情況.我無意中取消了該方法的注釋:
i ran into a situation very similar. i had unintentionally un-commented the method:
-(void)loadView
我相信這個方法覆蓋了 IB 接口,而是用這個代碼創建了它.檢查以確保它被刪除或注釋掉恕我直言.
i believe this method overrides the IB interface and created it from this code instead. check to make sure it is either removed or commented out IMHO.
這篇關于轉場后 iOS 5 黑屏的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!