4 개의 셀이 포함 된 컬렉션보기를 만들었고 셀 1의 버튼을 누르면 (다른 셀을 아직 만들지 않은 것입니다) "FirstCollectionViewController"라는 새로운 ViewController로 이동합니다. 컬렉션보기에서 스 와이프 할 때 슬라이드 아웃 메뉴를 보여주는 pangesturderecognizer가 있습니다.PanGesture로 인해 신속하게 EXC_BAD_INSTRUCTION (코드 = EXC_1386_INVOP, subcode = 0x0)을 얻는 중
그러나 "FirstCollectionViewController"에있는 상태에서 컬렉션보기로 돌아가려면 왼쪽 모서리에있는 단추를 누를 수 있습니다. 그러나 그것을 누를 때 CollectionViewController의 ViewDidLoad 내부에있는 "self.view.addGestureRecognizer (self.revealViewController(). panGestureRecognizer())"에서 EXC_BAD_INSTRUCTION 오류가 발생합니다. panGestureRecognizer를 ViewDidAppear에 넣으려고했으나 같은 일이 발생했습니다
어떻게 고칠 수 있습니까?
은 BTW 컬렉션보기로 다시 보내해야 SEGUE가 호출됩니다 : "SegueFirstCollectionViewController"CollectionViewController :
import Foundation
import UIKit
class CollectionViewController: UICollectionViewController {
var Array = [String]()
var ButtonArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
Array = ["1","2","3","4"]
ButtonArray = ["1", "2", "3", "4"]
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
override func viewDidAppear(animated: Bool) {
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return Array.count
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as UICollectionViewCell
let Label = cell.viewWithTag(1) as! UILabel
Label.text = Array[indexPath.row]
let Button = cell.viewWithTag(2) as! UIButton
Button.setTitle(ButtonArray[indexPath.row], forState: UIControlState.Normal)
// Button.addTarget(self,action:#selector(ButtonArray(_:)), forControlEvents:.TouchUpInside)
Button.addTarget(self, action: Selector("ButtonArray:"), forControlEvents:.TouchUpInside)
return cell
}
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("Inside didSelectItemAtIndexPath")
}
func ButtonArray(sender : UIButton) {
print("m")
if sender.currentTitle == "1"{
performSegueWithIdentifier("segueFirst", sender: nil)
}
if sender.currentTitle == "2"{
}
if sender.currentTitle == "3"{
}
if sender.currentTitle == "4"{
}
}
}
FirstCollectionViewController :
class FirstCollectionViewController : UIViewController {
@IBAction func SegueFirstCollectionViewController(sender: UIButton) {
performSegueWithIdentifier("SegueFirstCollectionViewController", sender: nil)
}
}
설명해 주셔서 감사합니다.하지만, 네비게이션 컨트롤러를 추가하고 콜렉션 뷰 (관계 '루트보기 컨트롤러'와 함께)에 연결하면 버튼이나 탐색 바가 나타나지 않습니다. FirstCollectionViewController (시뮬레이터에서)하지만 main.storyboard 안에있을 때 탐색 모음을 볼 수 있지만 버튼은 볼 수 없습니다. –