Xcode storyboard seque loops back to the same view - xcode

I am using storyboard seques to change views to other parts of my app but when I linked my main view to the next and called for the seque in the function within my enter button it just loops back to my main view and refreshes the app.
Here is my function call:
[self performSegueWithIdentifier:#"Enter" sender:self];
In the storyboard I have my main view linked to the next view with the identifier "Enter" but I still get send back to the same view. Is there any way to specify the destination of the next view? Do I need a certain variable from the other view controllers the need to be imported to the code of the main view controller?
I can provide more code or information if needed.
Picture: http://i1180.photobucket.com/albums/x411/Ryute88/screen.jpg
Identity Inspector Picture: http://i1180.photobucket.com/albums/x411/Ryute88/screen2.jpg
Picture 3: http://i1180.photobucket.com/albums/x411/Ryute88/screen3.jpg
Thanks in advance.

Please check this site: All about storyboarding
You will find details on doing your stuff.Try that and check if the problem still exists!

Are you using the write segue to call on the next view e.g. pop can only be used in case of Navigation Controllers.
In any case the problem will be trivial because storyboards do everything for you.

Related

PL buildiers version is implemented at two places in Xcode. How to set it right?

While writing an app in Xcode8 (swift3) for adding pictures with titles I set up two view controllers, the first of which was embedded in navigation controller. I’ve added an “Add” barbutton in the navigation control of the first view controller (VC), tapping which, the second view controller is shown. I receive the following error when I tap on the “Add” button on the 1st VC.
"objc[692]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x155d38cc0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x154b876f0). One of the two will be used. Which one is undefined."
Can somebody please help me understand the issue and to solve it.

Cannot connect IBAction to table view from xib

I am using this open source framework in swift https://github.com/uacaps/PageMenu for my view controller.
I am using xib for the tableview cells and the tableview as shown in the demo projects.
However, when I go to connect my buttons from the tableview cell to the table view controller Xcode will not let me. I am working on the NotificationTableViewCell and NotificationTableVC files.
I have set up the project properly and can get the cell up and running as well as the project itself. However if I can't get the buttons to connect I cannot add the needed functionality.
The demo projects also have this behaviour when I cloned some from the repository. I looked through the issues and no one seemed to mention anything about connecting IBActions to the view, so I did, but I assume there is something I am missing.
I have attached screen shots to help you see my issue. I need to access the cellForRowIndexPath as well.
My xib is given the class of my table view cell which still wont allow me to interact with the tableview controller.
Okay, so I have figured out a working solution. Thanks to Gurtej Singh.
Here is the code:
1) I added this line in the cellForRowIndexPath
cell.mybutton.addTarget(self, action: "declineRequest:", forControlEvents: .TouchUpInside)
2) Now I am able to access the button if I write a function called declineRequest
Since I want to delete the cell based on its data I use this function and add the Parse query logic.
func declineRequest(sender: UIButton) {
var cell: NotificationsTableViewCell = sender.superview!.superview as! NotificationsTableViewCell
.... }
I don't think you will be able to connect a table view cell element to a table view controller class via IB (and from what I know, it's not correct to do so as well, because there will be multiple cells and re-usability).
Connect the element from the IB to your Cell class (.h/.m), create one if you don't have it , like NotificationTableViewCell.m, and then access the connected element from the delegate methods inside your Table View controller class.
Hope this helps.

Switching from one view controller to another automatically

I have a project where a user fills in a web form, once the user hits submit it moves to a viewcontroller that shows a message "sent" or "error".
How can I make it automatically move to the main view controller without pressing a button, after a certain amount of seconds (so it displays the message "sent" for approx 2 - 3 seconds then moves to the main vc)
Any information would be highly appreciated, thankyou
Sean
You should be able to show the view and, in the viewDidLoad method (or viewDidAppear), set a timer to call a method that dismisses the view controller. Use performSelector:withObject:afterDelay to perform the delay.
Have a look here:
How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:?
You can trigger some code inside a block to run after a specified delay. Inside that code you can include your code to navigate to the other view controller.
The code for doing this depends on whether you are using storyboards or not. If you are using storyboards, you can use:
[self performSegueWithIdentifier:#"MySegueName" sender:self];
If you are not using storyboards, you can use the following to display the second view controller modally:
[self presentModalViewController:myNewViewController animated:YES];

Storyboards: A loop of Modal Segues?

I want to implement something using Storyboards, but I don't know the best way to accomplish it.
I don't want to use a Navigation Controller, since I don't want the navigation bar at the top.
I just want the ability to switch from one view controller to the next.
I have a Main Menu view controller, which will segue into other views, and those views might segue to other views... Now, lets say that the last view in the chain has a "Return To Menu" button: should I just segue from that button to the Menu view controller? Or should I somehow dismiss all of the previous view controllers?
I don't need iOS to hold a copy of the Main Menu view controller after the user taps out of it, but I can't seem to find a way to just load a new view controller and present it, instead of having a parent view display it "modally".
Would it cause a memory leak if I just create a loop of modal segues?
(for example: Main Menu --> VC1 --> VC2 --> Main Menu --> VC3 --> VC4 --> Main Menu...)
Any help will be much appreciated.
Thanks!
Each segue creates a new instance of the destination view controller, so having a segue back to the main menu is not a good idea.
You would be better off dismissing the presented view controller(s), but note that it is possible to use a navigation controller without showing the navigation bar - the navigation controller has a property, navigationBarHidden, which you can set to hide this.

Xcode create action when switching views

hi there im having real trouble i have a main view which i am able to switch to 2 new views and i am able to switch back from both them views to the main view which is amazing
but i would like when i switch back from say the first new view to the main view i want a label to display text
and the same thing to happen when switching back from the second new view but with a different label
so to sum it up i want to switch views and have a label saying i switched back from view 1 being controlled by the button used to switch back
any help would be amazing
Just put empty UILable on Main View. And set its value when you are doing transitions form first view to main view or 2nd view to main view.
How are you switching between views? If you are using a NavigationController, just set a variable on the main controller before you push/present the child controller.
Then, you can use that variable to set the label when you return to the parent view (viewWillAppear event).

Resources