In my project I am using a storyboard.
There is view controller MyViewController. MyViewController has button, on click of button it opens a Isgl3DViewController.
Isgl3dViewController has an animated 3d object. Isgl3dViewController also has a Close button, which dismisses the Isgl3dViewController and moves to MyViewController.
Now, when I am doing this first time, everything is working fine. I am able to see animated object and able to move MyViewController on click of Close Button.
But second time, when I click on MyViewController's button to display animation, Application being crashed again and again.
When it's working fine in first time then why app crashes in second time? Please help me out this.
For Reference I am attaching screenshot.
had the same problem, in my case because i add UI elements over the isgl3dview.
my workaround was substitute the UIView by a HUD.
Related
I am creating an app that requires notifications. I created a settings page with a switch to toggle notifications for the application. I tried to link the switch to ViewController2 using an #IBAction, but it keeps connecting the object to Exit, instead of ViewController. I am getting really frustrated because the #IBAction won't stay connected. I am not sure what is going on, but if I could get help that would be amazing.
The images are linked down below to Imigur.
This is the connection to ViewController2
This is what occurs when I connect the IBAction to ViewController2
You can see there is no action option for the connection in this image.
When you attach #IBActions (or #IBOutlets), you do not want to attach them to Exit on the View Controller.
Follow these steps to add an #IBAction:
1) Make sure your View Controller's class is linked to your file, then go into the Assistant Editor making sure you selected Automatic.
2) Hold Control (^) and drag the button to your ViewController class.
3) Add the button as an #IBAction. - It's also recommended to use UIButton as the sender, instead of Any.
It should look like this:
If you have questions, let me know!
The problem might be that you are supposing you can form an action connection from a UISwitch in the scene of one view controller to a different view controller. You can't. You can form outlets and actions only between a view controller and the interface inside the same scene of the storyboard.
Click on the top bar of your problematic ViewController (the overview of what is getting displayed on screen), click the top left icon (called View Controller).
On the right click "Show The Identity Inspector" icon and you should see class. Change the text to 'ViewController'. Hopefully it should auto fill.
This will solve the problem.
I have a ViewController/View in a TabBar Controller that has 8 UIButtons in a 2x4 grid, sized 75x75, each with a 75x75 background image set on them. Currently, I've hard coded the XY positions in the Size Inspector in Interface Builder.
When I first load the View, by clicking on the tab bar icon, the bottom two buttons get squished against the row above them - as per this picture:
Each button triggers a segue that launches another ViewController with a WebView in it :
[self performSegueWithIdentifier:#"playVimeo" sender:sender];
In that WebView, there is a back button that triggers another segue to return to the thumbnails page :
[self performSegueWithIdentifier:#"returnToThumbnails" sender:sender];
When I press the back button and return to the thumbnail view for a second time, the buttons snap to the right place, unlike when they first load, as per this picture:
Here is a screenshot of my Storyboard:
Does anyone have an idea what is going on here ? I am lost...
Thanks in advance!
Jesse
This issue went away when I unselected "Use Autolayout" in the file inspector of the UIViewControllers.
Though as rdelmar pointed out in the comments, it is funny that it was working at all, as I was actually creating a new ViewController with every segue from my back button, and not popping back to the previous existing ViewController. It should have been working the same in both ways, as the View was always loading 'for the first time' ...
I'm working on a word search puzzle game for the iphone and I'm trying to implement a restart button for the app. The restart button should be able to initialize a new view controller, generate a new puzzle, and display the new puzzle.
As of now, in the puzzle game view, I have a button that on-click it opens the pause menu view using a modal segue.(The pause menu have three buttons, resume, restart, main menu.) I then made the puzzle game controller a delegate of the pause menu, that receives the notification when the buttons are pressed. The resume and main menu button works, but I'm having trouble reloading the view with the restart button. The puzzle is inside a container view, that has a collection controller that creates the grid and displays the letter.
With the current code I have, when I click the restart button, all i see a black screen that only shows the navigation bar. But once I click the pause menu button(located in nav bar) and then click the resume button in the pause menu, i see the view with the new generated puzzle.
Below is the code in the pauseMenuController:
- (IBAction)IBARestart:(id)sender {
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
[self.delegate goToRestart];
}
Now here is the code in my puzzleGameController:
-(void)goToRestart{
self.view = nil;
[self.view.window setNeedsDisplay];
PuzzleCollectionControllerViewController *puzzleInstance = [self.childViewControllers lastObject];
puzzleInstance.view = nil;
[puzzleInstance.view setNeedsDisplay]; // I tried reloading the cointainer view too, but it still shows black screen
}
Anyone have any idea why is it showing a black screen? Thanks in Advance
I'm not sure if this is enough code, to get your problem..
But my concerns on this are:
Why do you "nil" self.view on restart? If you do this, the view is "nil" and therefore won't display anything, same for puzzleInstance.view.
You could nil / free the memory for this on viewDidUnload, as the view will get set again on viewDidLoad, but normally I just "nil" / "dealloc" any properties, outlets etc. (on viewDidUnload or dealloc, depending on where I set / re-set them) and not the view itself.
"setNeedsDisplay" will just "redraw" the view, but if it's nil, I'm afraid there is nothing to redraw. So I'm pretty sure that's your problem here.
What is different, or what is happening when you press "resume" (code?).
So I have an iPhone app. It has a simple structure, all based on a UINavigationController.
I have a storyboard that has one view, a segue to another view, etc. Now this other view has a UITextView that I do not want to edit on this screen - if the user taps this, I want it instead to fly over to a second screen which basically has the same text view, but this one is full-screen, and the user will edit the text on that screen before returning to the previous screen.
So I capture the textViewShouldBeginEditing method. I previously, in the storyboard editor, manually created a push segue from the previous view controller to this new view controller, and named it so that I can call it by it's identity, which I do with:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
// This is called when the user clicks into the textView as if to edit it.
// Instead of editing it, go to this other view here:
[self performSegueWithIdentifier:#"editMemoSegue" sender:self];
// Return NO, as I don't actually want to edit the text on this screen:
return NO;
}
Seems reasonable. And it works. Sorta. It does in fact shoot me over to that other view. That other view's events fire up, I set it's text view to become first responder, I edit the text on that screen. Everyone's happy.
Until I want to use the back button to return to the previous view.
Then I quickly find out - my navigation stack is foobared. Most of the time, I have, for some reason, TWO instances of my new editing controller on the stack, so the first time I hit the back button I get the same stuff over again. Then, oddly, occasionally, it will work as intended, and I will see my previous controller with only one back click.
I started reading the log, and I found this:
2012-12-09 09:41:03.463 APP[8368:c07] nested push animation can result in corrupted navigation bar
2012-12-09 09:41:03.818 APP[8368:c07] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2012-12-09 09:41:03.819 APP[8368:c07] Unbalanced calls to begin/end appearance transitions for <SecondController: 0x83881d0>.
So obviously, I'm doing something incorrectly here. The question is, what? And how do I do what I want in the way that correctly appeases the tiki gods of the iPhone framework?
Check to see if the textViewShouldBeginEditing is being called twice. I've noticed that these kinds of delegate calls sometimes are.
How is your #"editMemoSegue" being created on the storyboard? is it created from the textView? if it is then you should recreate it directly from the view controller or from the top status bar on the view controller that way it wont be called twice when you touch the trigger object and when you call it programmatically.
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.