2017-01-26 41 views
2

我有一個現有的應用程序,並希望創建一個iMessage擴展。iMessage擴展:從不同的目標獲取捆綁零件

,所以我必須在我的項目 現在我想表明我現有視圖中通過容器認爲延長 添加的目標的iMessage擴展英寸我已經添加代碼:

let mainBundle = Bundle(identifier:"com.marvel.nearby") 
print("MAIN_BUNDLE : \(mainBundle)") // getting nil 
let storyboard = UIStoryboard(name: "Main", bundle: mainBundle) 
let viewController = storyboard.instantiateViewController(withIdentifier: "MResourcesVC") 
self.showViewControllerInContainerView(viewController) 

斯威夫特的iMessage擴展類MessagesViewController.swift

,但得到爲零。我該怎麼辦?

如果這種方式是錯誤的在iMessage擴展中顯示viewcontroller的正確方法是什麼。請幫忙?

回答

2

你必須在storyboard.storyboard文件添加到您的目標:

爲了得到正確的包,使用:

Bundle(for: type(of: self)) 
+0

我想,但我已經通過捆綁來訪問它,我得到捆綁無 –

+1

已更新的答案。 – shallowThought

+0

還有一個如果安裝了pod,我該如何使用它? –