2016-04-29 34 views
1

我在一個非常深的鹹菜。我意識到有很多關於我的錯誤的SO主題,並且我已經通過了這些答案的3-4頁谷歌搜索結果,並嘗試了所有解決方案。沒有工作。Segue錯誤:ViewController沒有標識符的繼承

什麼㈣嘗試:

  1. 重置模擬器設置
  2. 清理Xcode中建立文件
  3. 重命名故事板
  4. 檢查是否確定賽格瑞沒有拼寫錯誤(上百次)
  5. 重新啓動並重建xCode項目
  6. 確保segue實際上與錯誤中的ViewController相關聯河

問題:輸液從製成的SEGUE ViewProjectViewControllerRecordModule。然後,我編程添加了一個條形按鈕到NavBar的ViewProjectViewController,因爲那個導航欄是從前一個VC編程製作的。

然後,您可以爲'item3'..這是按鈕,我點擊運行該函數performSegueWithIdentifier。但是,當我點擊它,我得到這個錯誤:

2016-04-29 12:54:59.098 music[9298:1272742] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<music.ViewProjectViewController: 0x7bead670>) has no segue with identifier 'recMod'' 
*** First throw call stack: 
(
    0 CoreFoundation      0x00ac3494 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x02e9be02 objc_exception_throw + 50 
    2 UIKit        0x01b4971c -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0 
    3 music        0x00089ad8 _TFC5music25ViewProjectViewController13openRecModulefPs9AnyObject_T_ + 168 
    4 music        0x00089b4a _TToFC5music25ViewProjectViewController13openRecModulefPs9AnyObject_T_ + 58 
    5 libobjc.A.dylib      0x02eb00b5 -[NSObject performSelector:withObject:withObject:] + 84 
    6 UIKit        0x01977e38 -[UIApplication sendAction:to:from:forEvent:] + 118 
    7 UIKit        0x01e079da -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 179 
    8 libobjc.A.dylib      0x02eb00b5 -[NSObject performSelector:withObject:withObject:] + 84 
    9 UIKit        0x01977e38 -[UIApplication sendAction:to:from:forEvent:] + 118 
    10 UIKit        0x01977db7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64 
    11 UIKit        0x01b1bf3b -[UIControl sendAction:to:forEvent:] + 79 
    12 UIKit        0x01b1c2d4 -[UIControl _sendActionsForEvents:withEvent:] + 433 
    13 UIKit        0x01b1c483 -[UIControl _sendActionsForEvents:withEvent:] + 864 
    14 UIKit        0x01b1b2c1 -[UIControl touchesEnded:withEvent:] + 714 
    15 UIKit        0x019f852e -[UIWindow _sendTouchesForEvent:] + 1095 
    16 UIKit        0x019f95cc -[UIWindow sendEvent:] + 1159 
    17 UIKit        0x0199abe8 -[UIApplication sendEvent:] + 266 
    18 UIKit        0x0196f769 _UIApplicationHandleEventQueue + 7795 
    19 CoreFoundation      0x009d5e5f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
    20 CoreFoundation      0x009cbaeb __CFRunLoopDoSources0 + 523 
    21 CoreFoundation      0x009caf08 __CFRunLoopRun + 1032 
    22 CoreFoundation      0x009ca846 CFRunLoopRunSpecific + 470 
    23 CoreFoundation      0x009ca65b CFRunLoopRunInMode + 123 
    24 GraphicsServices     0x05d4e664 GSEventRunModal + 192 
    25 GraphicsServices     0x05d4e4a1 GSEventRun + 104 
    26 UIKit        0x01975eb9 UIApplicationMain + 160 
    27 music        0x000a7391 main + 145 
    28 libdyld.dylib      0x040a1a25 start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

繼承人我的代碼(視圖控制器 - 啓動Segue公司的點)

class ViewProjectViewController: UITableViewController { 




    var selectedProj: Array<String> = [] 
    var selectedKey: String = "" 


    var listItemsTwo = [ListItemTwo]() 

    let shareDataTwo = SharedDataTwo.sharedInstance 


    override func viewDidLoad() { 
     super.viewDidLoad() 

     // Setup Left UIBarButton Here 
     self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "BackBtn"), style: .Plain, target: self, action: #selector(ViewProjectViewController.backButtonPressed(_:))) 


     // Setup Right UIBarButton Here 

     var items : Array<UIBarButtonItem> = [] 


     let item1 = UIBarButtonItem(image: UIImage(named: "SaveBtn"),style: UIBarButtonItemStyle.Plain, target: self, action: #selector(ViewProjectViewController.saveChanges)) 

     let item2 = UIBarButtonItem(image: UIImage(named: "EditBtn"), style: .Plain, target: self, action: #selector(ViewProjectViewController.editProject)) 


     // SEGUE BUTTON NOT WORKING ////////////////////// 
     let item3 = UIBarButtonItem(title: "Record", style: .Plain, target: self, action: #selector(ViewProjectViewController.openRecModule)) 
     item3.tintColor = UIColor.redColor() 

     items.append(item1) 
     items.append(item2) 
     items.append(item3) 


     self.navigationItem.setRightBarButtonItems(items, animated: true) 




     item1.setTitleTextAttributes([ 
      NSFontAttributeName: UIFont(name: "Aldrich", size: 12.0)!], 
              forState: UIControlState.Normal) 

繼承人的SEGUE代碼(ViewProjectViewController)

func openRecModule(sender: AnyObject) { 
    self.performSegueWithIdentifier("recMod", sender: nil) 
} 

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 

    if let destinationVC = segue.destinationViewController as? RecordModule { 
     destinationVC.transitioningDelegate = self 
    } 



} 

Interface Builder Image - http://i.imgur.com/klbwdrm.png

ViewProjectViewController如何顯示在螢幕上

MainPanelViewController將用戶定向到ViewProjectViewController

MainPanelViewController的UIViewController的UITableView包埋內部。對於的UITableViewCell的代碼如下(這也是順着接下去ViewProjectViewControlle R)

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 

     let keys = Array(sharedDataThree.c.keys) 
     let object = self.sharedDataThree.c[keys[indexPath.row]] 

     let newProgramVar = object as! NSArray 

     let destinationVC = ViewProjectViewController() 

     destinationVC.selectedProj = newProgramVar as! Array<String> 
     destinationVC.selectedKey = keys[indexPath.row] 

     //performSegueWithIdentifier("viewProject", sender: self) 

     var alreadyPushed = false 

     if let vc = self.navigationController?.viewControllers { 
      for viewController in vc { 
       if let viewController = viewController as? ViewProjectViewController { 
        self.navigationController?.popToViewController(viewController, animated: true) 
        print("Push your controller") 
        alreadyPushed = true 
        break 
       } 
      } 
     } 
     if alreadyPushed == false { 
      self.navigationController?.pushViewController(destinationVC, animated: true) 
     } 
+0

打開故事板文件,然後搜索「recMod」 - 確保它看起來像什麼,你認爲它應該(嵌套在正確的地方)。如果你無法弄清楚,我想你可以把它放在一個要點,並把它鏈接到這裏。 –

+1

另外,你是如何在屏幕上獲得ViewProjectViewController的?你有繼續嗎?你從故事板加載它,對吧? –

+0

我記得有這樣一個奇怪的問題。你有沒有嘗試過「清潔生成文件夾」? Command + Option + Shift + K會這樣做。 – James

回答

0

試試這個:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 
    if segue.identifier == "recMod" { 
     let destinationVC = segue.destinationViewController as? RecordModule 
     destinationVC.transitioningDelegate = self 
    } 
} 
+0

它看起來像prepareForSegue尚未被調用 - 它根本找不到segue。 –

+0

謝謝@Jitendra我已經嘗試過與此相同的錯誤! – brkr

+0

請調試您的代碼並查看錯誤來自哪裏。請分享日誌中的錯誤說明。如果問題中提到的錯誤是相同的。嘗試刪除/刪除segue,然後再添加segue到控制器併爲其指定另一個名稱;在代碼中更改它也是如此。然後驗證它的工作與否 – Jitendra

0

你的問題是這樣的一行:

let destinationVC = ViewProjectViewController() 

你沒有從故事板加載它。這個班級裏沒有任何東西可以知道你也可以從故事板上創建它,所以這些段落不在那裏。

嘗試是這樣的:在一個普通的文本編輯器

let sb = UIStoryboard(name: "yoursbname", bundle: NSBundle.mainBundle()) 
let destinationVC = instantiateViewControllerWithIdentifier("YourVcID") as? 
相關問題