2013-12-21 42 views
11

我有一個導航控制器,它們之間有一個叫做「addSegue」的segue鏈接。當我點擊tableView細胞雖然應用程序崩潰,我得到的錯誤如下:'接收器(<ViewController>)沒有帶標識符'addSegue'的segue

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<MSAddFriendsViewController: 0x98cc340>) has no segue with identifier 'addSegue' 

我不認爲我有我的代碼的任何問題。這是在我行showSegueWithIdentifier方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
NSMutableSet *selectedUsers = [NSMutableSet set]; 

[self.tableView deselectRowAtIndexPath:indexPath animated:NO]; 
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 


cell.accessoryType = UITableViewCellAccessoryCheckmark; 
PFRelation *friendsRelation = [self.currentUser relationforKey:@"friendsRelation"]; 
PFUser *user = [self.allUsers objectAtIndex:indexPath.row]; 
[friendsRelation addObject:user]; 
[self.currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { 
    if (error) { 
     NSLog(@"Error %@ %@", error, [error userInfo]); 

    } }]; 

[self performSegueWithIdentifier:@"addSegue" sender:self]; 

} 

Here is a picture of my storyboard

Here is an updated picture of my storyboard

+0

檢查您在Storyboard中給出的Segue標識符。 –

+0

清理項目並重試。 –

+0

你應該在一個不需要人們看到它的權限的網站上發佈故事板的圖片。 – rdelmar

回答

6

很難肯定地說,但其他一些人也有類似的問題:

  • this question中,提問者用 實例化故事板而不是instantiateViewControllerWithIdentifier,所以 segue沒有正確設置。

  • this question,這只是對 會在內部與Xcode和模擬器奇怪的事情,並運行產品 - >清潔 幫助。

  • 當然,有可能代碼中的segue名稱與Storybord上的segue名稱不匹配,但我猜你已經檢查了很多次了!

11

enter image description here

use segue identifier in Push Method and give the proper connection 

如果您使用Identifier,然後調用這條線,其中u需要

[self performSegueWithIdentifier:@"identifierName" sender:self]; 

斯威夫特2.X

self.performSegueWithIdentifier("identifierName", sender: self) 

斯威夫特3

self.performSegue(withIdentifier: "identifierName", sender: self) 

關於您添加這樣的新屏幕。在該屏幕上,當你完成並想刪除它,它只是:

self.dismiss(animated: false, completion: nil) 
+0

如何使用此方法將值傳遞給下一個視圖控制器? – Aniruddha

+0

@Aniruddha - 昨天我已經回答你的問題,如果你不是我的我解決了你的問題,你可以發送你的項目在郵件ID [email protected] –

+0

我使用的故事板。我有兩個類A和B.從A,我想將值傳遞給B.這是我如何做,但它不工作。 'B * bb = [[B alloc] init]; b.strName = @「Abcd」; [self performSegueWithIdentifier:@「segueName」sender:nil];'。請不要介意我不能把你的項目發給你。 – Aniruddha

16

我有同樣的問題,實際上我的問題是,我打電話

WRONG: [self.navigationController performSegueWithIdentifier:@"ShowVerify" sender:self]; 

,而不是

CORRECT: [self performSegueWithIdentifier:@"ShowVerify" sender:self]; 

所以請您呼叫的正確performSegueWithIdentifier方法:)

+0

不錯的一個,這是我的情況 –

+0

謝謝,我有反向的情況下。 –

0

檢查是否UIKit的b eing或不在頭文件中。我在不知不覺中將新的VC作爲View Controller的一個子類。

相關問題