I'm a beginner of Swift and XCode. When I tried to establish connection between a button and a "showMessage" method as is described in this tutorial, the "showMessage" method cannot be found in the pop-up menu.
Then I downloaded the code zip of the tutorial, and run it in XCode. I got error:
"Launch screens may not have triggered segues. (LaunchScreen.storyboard)"
The error storyboard is a main storyboard, not a launchscreen storyboard. Someone may have this trouble because he unintentionally checks "Use as launch screen" for a main storyboard. However, it's not checked in this case.
Where is wrong and how to fix it?
P.S. My XCode version is 8.2.1.
You can not segue through the LaunchScreen.storyboard. Make it through Main.storyboard.
Set one:
check for Use as Launch Screen
and uncheck "Use as Launch Screen"
Set TWo:
check for Is Initial View Controller
and uncheck "Is Initial View Controller"
Set Three:
run your project again.
Related
When I click on my Storyboard file, I can't see the UI I made.
It's showing some code instead of my UI.
How can I see my Storyboard user interface?
Press this button to see your UI back. This is not an issue it is a feature of Xcode to see your code behind the storyboard's UI
I am trying to build an app, and I want another view to open up once I click a button. I have searched for an answer, but nothing came up. I already have the button done, but I don't know how to get another view to show up. The view should be another view within the app. I am just a beginner in xCode. Thanks.
I am currently using xCode 9, and swift 4. Thanks.
You can approach this either using the storyboard or programmatically. Using the storyboard, you can ctrl-drag from the button to the other view controller and the segue will be wired up for you, like so:
If you aren't using storyboards at all, you can use the .show method of the ViewController in the button action. Apple has a good guide on segues.
I am new to swift / Xcode and I am trying to create a button in Xcode that can randomly transfer to a different storyboard. I tried following the instructions in this post to do it (I also tried other ideas, but this answer was the most intuitive)
How to Segue Randomly to ViewControllers in Swift?
I've written the IBAction and connected the extra storyboards with different segues to the root view controller but when I start the simulation nothing happens when I click the "go" button. I cannot connect this button with the IBAction by a control drag, so I think that may be the problem.
I've tried creating new projects, connecting the "go" button to the root view controller, and editing the classes (it doesn't let me). What else could be wrong? My code is exactly like the answer to the link I posted. Is there a step missing to that answer?
First make sure you created a custom class for your root view controller. Also make sure you assigned your custom class to the view controller in Interface Builder.
Try dragging from your button to the view controller code pane and let XCode create the IBAction stub for you. Now touching the button should trigger your IBAction.
I am currently learning iOS development and I began with a simple Tabbed Application. It has the default First and Second View in it. I added a TableView with static cells content. I then added another View Controller. I created a Segue using the storyboard. When I set the transition to modal, it works fine. When I set it to push, the app is crashing (Uncaught exception).
Any idea why?
How can I get more information regarding the exception? Can I make the app stops when it encounters an exception?
Figured it out.. I need to add a Navigation Controller to use push...
This is strange. I have a custom Nib with a webView, all outlets are set properly. On the first "Build and Run", whenever I invoke the nib, it's just a blank white screen with my iPhone status bar at the top. Then, if I click Stop, and Build and Go again (without making any code changes) and I invoke the nib, I get my Nib from Interface Builder exactly the way it should be, operating just fine.
This lasts and works until I make any changes in the custom view controller. If I make a change and want to test, I have to Build and Go, Stop, and Build and Go again to get my nib to display properly.
Has anyone ever experienced this? My ViewController is displayed modally.
Keep in mind that I don't make any code changes at all between Build and Go attempts.
The answer to this problem is that there are 2 nibs with the same name in the bundle. I am not sure how this happened, but I decided to check my connections (again) and when I opened the nib, it was empty. "That's odd." I thought to myself. I went to double click it again and wondered why it was at the bottom of my "Classes folder." Lo and behold, I had an extra one inside my project, as well as the original in the resources.
Just an FYI! I guess you can have two of the same file in the bundle...