-1

I have searched for a similar question to this but cannot find it because mine is very obscure.

I am currently developing a social network app. All my code seems to be correct. However, there is the share button that is not working. I will attach the code here:

@IBOutlet weak var shareBtn: UIButton!

which is in one of my files to connect it up and:

@objc func toCreatePost (_ sender: AnyObject) {
    performSegue(withIdentifier: "toCreatePost", sender: nil)
}

Before you ask, all of my segues are connected, the buttons are connected to the code and the identifier is correct.

I don't know if it could be an error in Xcode itself or my code, but the button clicks when it is run however it does not do anything. Help would be appreciated. The error is that when the button is clicked it does not do anything and will not go to the next ViewController even though the code seems to be correct.

@IBAction func toCreatePost (_ sender: AnyObject) {
    performSegue(withIdentifier: "toCreatePost", sender: nil)
}

Above is the code with an IBaction which I edited which now gives me a crash. The crash is a Thread 1: signal SIGABRT

Here is my main.storyboard

main.storyboard image.

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
  • Put a breakpoint in the action. Does your app halt when the button is pressed? If not, there *is* a problem with your target/action pattern. – Tamás Sengel Jul 02 '18 at 17:42
  • Does `toCreatePost` get called (i.e. put a breakpoint or a `print` inside it)? – Grimxn Jul 02 '18 at 17:43
  • do you have a `shouldPerformSegue` or `performSegue` that makes it retrurn without performing the segue? – Daniel Jul 02 '18 at 17:44
  • The toCreatePost is an identifier used in the storyboard where the shareBtn is connecting to the new screen – Charlie Jones Jul 02 '18 at 17:50
  • @rmaddy I have changed it to a IBAction. Then reconnected this to the shareBtn however I am getting a crash when this is done. Any ideas? – Charlie Jones Jul 02 '18 at 18:18
  • Please check this out https://stackoverflow.com/questions/8295471/storyboard-doesnt-contain-a-view-controller-with-identifier – Sazid Iqabal Jul 02 '18 at 20:12
  • If there is a crash, please show the error message you get in console/debugguer. – Larme Jul 02 '18 at 21:01
  • libc++abi.dylib: terminating with uncaught exception of type NSException . That is what is in the console @Larme – Charlie Jones Jul 02 '18 at 21:51
  • Full error message please. Starting from « Terminating with «  (with an uppercase) – Larme Jul 02 '18 at 21:52
  • My Bad there, didnt read upwards. – Charlie Jones Jul 02 '18 at 23:07
  • Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SocialApp.FeedVC shareBtn:]: unrecognized selector sent to instance 0x7f88af50e7a0' libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) – Charlie Jones Jul 02 '18 at 23:08
  • only put the relevant info in due to too many words @Larme – Charlie Jones Jul 02 '18 at 23:08
  • You don't have a IBAction method named `sharedBtn:`, is it `toCreatePost:`? Remove the connection from I guess the `var shareBtn` to the `shareBtn:` method in Interface Builder. – Larme Jul 03 '18 at 07:29
  • in "@objc func toCreatePost (_ sender: AnyObject) {...}" it seems like you're performing by adding a target check that method properly, it should work then – Mohit G. Oct 16 '18 at 10:07

1 Answers1

0

See this for view-based issues click here

It seems you have not added navigation controller before the view controller from where you have to perform segua action.

if your problem still not resolved try to push manualy without segua

Sazid Iqabal
  • 409
  • 2
  • 21