問題描述
我有一個(gè)帶有情節(jié)提要和兩個(gè)場(chǎng)景的 iOS 5 應(yīng)用程序.場(chǎng)景 1 是一個(gè)選擇列表,而場(chǎng)景 2 顯示每個(gè)選擇的詳細(xì)信息
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
在場(chǎng)景 1 中,我需要傳遞一個(gè)變量,我這樣做:
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];
}
}
在場(chǎng)景 2(細(xì)節(jié))中,我使用它來驗(yàn)證是否收到了正確的變量
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];
}
所有這些都可以正常工作,并且警告框會(huì)顯示正確的變量,并且會(huì)過渡到新場(chǎng)景.但是,警告框總共顯示 5 次以上 &結(jié)束,一旦完成,整個(gè)窗口都是黑色的.那時(shí)我的場(chǎng)景(場(chǎng)景 2)中沒有顯示任何內(nèi)容.所以我知道我有正確的轉(zhuǎn)場(chǎng),它會(huì)根據(jù)需要轉(zhuǎn)換,我只是在屏幕上看不到任何東西.
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
我相信這個(gè)方法覆蓋了 IB 接口,而是用這個(gè)代碼創(chuàng)建了它.檢查以確保它被刪除或注釋掉恕我直言.
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.
這篇關(guān)于轉(zhuǎn)場(chǎng)后 iOS 5 黑屏的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!