This is really bugging me to the point where I'm going to have to step away for a bit.
So I am coding away and decide to change which ViewController gets launched on startup. I go into the app delegate and make the changes so that the the new ViewController will get loaded on startup, but when I run it in the simulator, the old one appears.
I've cleaned out the simulator, and i've tried "touching" files to force a relinking of the resources and it doesn't seem to make a difference. I can get an error to happen when I change the name of the ViewController in the app delegate to something like "vc". I then get a linking error saying the key value pair isn't found.
Anyways, if I am trying to just change which viewcontroller starts up in the app delegate, is there anything other than coding changes that I need to look at to inform xcode that I'm doing this? I've been searching google and working on this for the last couple hours and not really making any progress. If it makes any difference, this is for an ipad app.
Did you connect the controller IBOutlet of the app delegate with the your view controller?
Check your main XIB file in InterfaceBuilder.
And of course don't forget to save your changes made in InterfaceBuilder before launching the app since there is no "auto-save".
Related
I was making a user interface using storyboards and when I built my app to see how it would look in the iOS simulator it didn't look like the viewcontroller in the storyboard (some of the buttons were moved around and I had to move one button way down so it was in the place i wanted it to be). Does anyone know why this is?
Yes, the reason is auto layout, it will automatically position elements on a relative basis depending on the device you're running.
You can turn autolayout off, or build for all devices at once and keep it on.
You may want to read iOS Auto Layout Demystified by Erica Sadun which goes in depth to the world of autolayout.
I am working with my first tabbed application in xcode. I am just testing with some stuff since I'm relatively new to programming. I am just using the 2 views already put into the template. I am putting a slider into the first view and am going to attach it to a text box with numbers. But that isn't the problem! This is probably really stupid and simple, but when i run the application just to see the stuff on the simulator, it is just showing a black screen. NO CLUE WHY! But its killing me and would love some help!
You are not suppose to make connections in AppDelegate. You should use a ViewController for each class. I.E. FirstViewController, SecondViewController. AppDelegate is usually only used for calling save/restore messages.
You are getting the error because the storyboard view is assuming you are assigning it to the correct view. When you create the storyboard say you named it TestApp. Then, you should have a few classes. TestAppDelegate, TestAppDelegateFirstViewController, TestAppDelegateSecondViewController. Or something along those lines. FirstViewController should connect to the first view on the tab view. The Second should attach to the second.
AppDelegate is almost never used for UI. I would suggest you find a book on the matter. I'll suggest "iOS Programming. The Big Nerd Ranch Guide". It helped me a lot when I started.
Photo Exmaple:
I did end up starting a new project. Weird that the black screen showed up.. not really sure why that error was popping up.. I'm not really that knowledgable about the different errors and bugs that a program can have yet! Getting closer though!
I'm quite new to iOS Programming. I've done Objective-C for about a year, and now I want to start making apps for the iPhone. I think I'm missing out on something really simple, though. What I've done is this:
First I created a new Single View Application with TestApp as a product name. I enabled Use Storyboards, Use Automatic Reference Counting and Include Unit Tests. After creating the project, I dragged a UIButton onto the View in the storyboard file.
Note that I didn't write a single line of code. I launched my app in the iPhone Simulator and pressed the button, but it's not responding. I know I didn't assign an action to the press of the button, but the gradient of the button isn't changing, as I know it should. The User Interaction Enabled properties of both my view and my button were enabled.
Recently, I've created a few apps in Xcode that worked just fine, but I didn't use storyboards in those projects. Thus, I'm guessing there's something extra to do when using storyboards of which I'm just unaware. I'm using Xcode 4.5 and the iPhone 6.0 Simulator.
I wrote NSLog(#"View was loaded."); statement in the viewDidLoad method of my ViewController to make sure this view controller was actually loaded. (I know my button wouldn't show up if it was the wrong view controller, but I did this just to make sure.)
I also wrote a changeTitle: method in my ViewController to change the title of my button to New Title after it was pressed, just in case the button worked but its gradient just wouldn't respond to a tap. I linked this IBAction to my button, but it wasn't called.
In my ViewController, I created an IBOutlet of a UIButton which I connected to my button. In the viewDidLoad method of my ViewController, I changed the title of my button to New Title, this actually worked. The title of my button changed to this new title when launching my app in the iOS Simulator. The button itself still wasn't responding, though.
As a last try, I also wrote [button setEnabled:YES]; in my ViewController's viewDidLoad method, but this didn't help. My button still doesn't respond to any tap. What am I missing out on?
This is weird. I had an issue with my printer, so I restarted my computer. After this, this issue was suddenly solved as well (just like my printer issue). I'm not sure how this could have affected anything, but I'm glad it works again!
Ran into the same issue.
Apparently Content Reseting the Simulator worked for me
Very strange this..
I have downloaded Xcode 4.2 and I'm having problems viewing my project in the simulator. I'm getting a blank whit view when I run the simulator. I'm using a single view application. I created a interface .h, .m, .xib... I have connected all actions and outlets and saved everything. My thoughts are that I have overlooked something simple. again, I just started using Xcode 4.2 today. Help!
I am assuming you are not doing this
if((self = [super initWithNibName:#"MyClass" bundle:nil])) {
// do stuff here
}
This isn't enough information to tell what's wrong with your code.
That said, if create new project in XCode using the "Single View Application" template you can see how everything is hooked up and you may be solve your problem with a 'how is mine different?' comparison.
If that fails... post some code and we might be able to see the issue.
Edit: From your screenshot it looks like you are mixing storyboards and XIBs. If you are using storyboards, then you won't see .xib files. They are inside your storyboard. You can click on the storyboard file and edit the first XIB which loads when your app runs as well as create new ones. You can still do things the "old" way by just unchecking storyboards when you first create the app. On a side note, it is possible to mix storyboards and straight XIBs, but I don't think that's what you were going for.
At a guess, you created a project with storyboards, then added a XIB manually and you get a blank XIB. Try clicking on the storyboard and modifying the XIB in there. I bet they will show up when you run your app.
At the moment I am experiencing a really weird behavior of my Mac App.
On my Mac (and on all other testing Macs) everything works fine. The app simply works, no leaks,...
BUT on all the review Macs (Yes, on all) it fails: First the launch failed and now, after submitting it more times and trying to workaround the bug, it does not get initialized: Icons that should get loaded dynamically are not shown.
WHY?! Perhaps anyone has made experiences with such a problem because I cannot test it. I try to find the issue but it's nearly impossible.
[EDIT]
App Information:
My app should list all the currently running applications and display them in some way. It reads no files, only the NSUserDefaults to setup itself.
Structure:
appDidFinishedLaunching setups basic stuff like global hotkeys, loads the NSUserDefaults and finally forwards the message to the subclassed main window (<- There is the problem).
There it should load its interface which does not work on review Macs.
I was able to "override" or "fix" this by a little, dirty code snippet but it does not fix the main problem:
//AppDelegate.m
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self performSelector:#selector(didLaunch) withObject:nil afterDelay:0.5f];//<- THIS does the trick, so that the app launches and shows the static content of the NIB, but NO dynamic content is displayed: exactly the same nib state
//Register hotkeys, load NSUserDefaults,
[mainview launched];//<- Here is the problem
finishedLaunching=1;//global var
}
-(void)didLaunch//Launching works
{
if (finishedLaunching==0) {//=0 because of the review results
//Does all the stuff that [mainview launched]; is supposed to do: Display window and setup position
//Calling methods included in main view does not work (OR the window is not refreshed
//so the first start finally works, but the interface is EMPTY, only static content visible
}
}
Does the setup not happen because it is done in its subclassed window?
Why does it work on my Mac (and another Mac mini)?
Do you know why this happens, a way how to correct it or how to reproduce the bugs?
I really need your help and appreciate every tip!