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...
Related
I've been developing a macOS app using a storyboard that defines a main window with toolbar and splitview. It's written in Swift 3 -- I have not migrated to Swift 4 yet. The splitview has a pane for graphics and another for a text log; both scroll. I have view controllers for all three; the two subsidiary scenes are tied to the split view with relationships. This worked up until today when I installed Xcode 9 beta 4. (Yes, I have beta 3 in the trash at the moment and can revert)
Upon cleaning the build folder and compiling, I get the error
NSSplitViewController's 'view' outlet should not point to its NSSplitView; use the 'splitView' outlet instead
However, the NSSplitViewController subclass has no outlets defined (its two children arrange to tell it of their existence in their viewDidLoad methods). Moreover, I don't seem to be able to create an outlet between that window and its controller that would have created the error in the first place.
I now also note that the split drawn in the split view controller's scene is horizontal instead of vertical as it had been. I don't see a way to change that. (I can't run the app, so I don't know if it matters. I suspect it does.)
The net result is that I can't see what the error is trying to tell me. The error prevents the application from building and running, whereas with beta 3 it worked. I'm hoping someone can explain what Xcode is telling me and how to fix it.
I did fix this in my own Storyboard. In the outlets window, I saw that the view outlet was indeed assigned to the NSSplitView. I deleted it. It was also assigned to the splitView outlet, so the change did not seem to effect anything.
The warning went away and my project then did build.
I have no idea if this was always that way and compiler update changed or if this was somehow inadvertently set differently in some way. It makes sense in any case, the NSSplitview should be assigned as the splitView outlet, not the view outlet.
I'm working on an iPhone app again and I'd like to setup one view to be seen before another. I've added the view to my window and have specified the viewcontroller code that I'd like to use, but I can't find where on earth xcode specifies which viewcontroller in the window is displayed first. I'm sure it must be something obvious. I thought that the appdelegate seemed logical, but I don't see it displayed there. Any help? :(
Usually it is in the UIApplication setup code. Also try looking in your xib file as to the linkages setup there!!!
Without seeing more code or your setup, this is the best I can do!!!
As you can open the MainWindow.xib file you can see the part on the windows that specifies that from which viewcontroller it is gona load. (Like "Loaded From "RootViewController""). From the inspector of the window there is an option called NIB Name that gives you a list of view controllers available in your project.Changing these will change the setting of from which view controller you want to begin your app.
Hope this will help you.
So, this is kind of hard for me to explain, but i will do my best. I am most likely making a simple mistake, but i cant figure it out. So, im on my mainstoryboard, with a round rect button on the controller. I open the dual view editor and open up the viewcontroller.h file. Now, i should be able to press control and drag the button connection in the .h file, but i cant. It wont give the option to. Does that make sense?
Any ideas?
http://www.youtube.com/watch?v=62Xfn5oAjw0
Edit: For example, i need to do the part at 3:08, but it won't allow me to do that.
Edit 2: Ok. So, i put the button on a single view controller, and everything worked the way it should. BUT, when i put the same button on a tab bar view controller, it doesn't play the sound it should when pressed. The sound played when it wasnt on the tab bar controller just fine though.
EDIT: I watched the video and I know what you're doing. You're trying to create an outlet. When you right click the button there'll be a circle that says "New referencing outlet". Try dragging that circle to the viewcontroller. Otherwise, just type what comes up after he does that manually. Easy.
It should already be connected automatically. You never actually drag the button to the view controller. The view should already be connected and therefore any part of the view is connected. However, if you're having problems in the future, try this to sort of start over.
What you're going to want to do is go up to file>New File
Then you're going to want to select a new view controller, and make sure you tick the box that says "Include a XIB" or something similar.
After that, it will make all the connections you need. Any part of the view will automatically connect to the view controller, and all you'll need to do is create the IB actions to preform things in the interface and connect them to buttons when you're ready.
You have to set the viewcontroller as the file owner of the view. This is done in the story board.
I don't understand why you'd want to ctrl+drag the button to your ViewController.h . If you wanted to link the button to a ViewController in the storyboard, then you just ctrl+drag it to that ViewController. I may not have understood your question, but I think this is what you want.
the iphone app I am writing shows white screen when first launched, but become okay when entered again.
when I press home button of iphone, then enter the app again, it displays correctly.
(actually when I have just pressed the button and when seeing the app goes from foreground to background, I saw the correct app root display)
This problem also happen when I haven't enter the app for a certain period of time.
Anybody has ever encountered this problem?
How can I solve it? Thanks!
you may not be setting the rootViewController in applicationDidFinishWithOptions: but instead setting them in applicationWillEnterForeground
could you post your code for those two functions so we can see
Based on your description I'd say that in your app delegate, the code you want in application:didFinishLaunchingWithOptions: is in applicationWillResignActive:.
I couldn't have described my problem better myself, so you can imagine my frustration at the answer not being here yet. To that end I'll add my solution:
Given that you're doing the right stuff in your applicationDidFinishWithOptions: method and not in applicationWillEnterForeground, something along the lines of:
navcontroller = [[UINavigationController alloc] initWithRootViewController:homeViewController];
[window addSubview:nc.view];
[window makeKeyAndVisible];
make sure to double check the following:
Your delegate is hooked up to the appropriate window in your MainWindow.xib
You've ticked the "visible at launch" box in interface builder for the window.
In your Target Info (or info.plist) make sure "Main nib file base name" is "MainWindow"
This is the bit that caught me out - if you have two windows in your mainwindow nib (I had a second that I use later to display a full screen image) make sure that you hide it, I set it to hidden in interface builder and unhide when you need it, I also unchecked the "visible at launch" box for good measure.
From a spot of googling I found that if you're getting a white screen you'll likely be getting an "Applications are expected to have a root view controller at the end of application launch" error, meaning the delegate can't find a nib to load, however if you're getting a black screen and nothing in the debugger then it is loading some nib just not necessarily the one or the part of one you're expecting. Mine was loading the blank window over the one that I wanted (the one with the correct nib in it), (I think).
Happy bug fixing!
In my iOS 5 project, using ARC and Storyboards, I feel that I have run into a strange behavior. I would like to confirm if what I am experiencing is in fact the default behavior AND if it can be modified.
I have a NavigationController with a RootViewController in story board. Neither of these is tied to a specific subclass. On RootViewController I have a button that is connected to a segue for a ListingViewController, which makes a static call to a web service (does not vary by user input). What I have noticed - at least in the simulator - is that when I press the button, go back, and press it again, the second time it loads unrealistically quickly! It seems as though the ListingViewController is being cached.
Is this supposed to be happening? What can I do to fix it?
Is this supposed to be happening? What can I do to fix it?
Why do you think it's broken? I haven't looked into whether the storyboard holds onto its view controllers, but it wouldn't be surprising if it does.
If you're doing something like making your web service request in -viewDidLoad, but you want it to happen every time the view appears, you should move that to -viewWillAppear or -viewDidAppear.