How to load existing TableViewController on click of button iOS5 - ios5

I created UIExamsTVC using storyboards.
Once cell is clicked, it takes me to UITestVC.
UITestVC has 10 questions, When I get to the last question #10, there I have a "Done" button. I would like to go back to the original UIExamsTVC once the 'Done' button Clicked.
In: UITestVC.m
#import UIExamsTVC.h
(on button click)
[self.navigationController pushViewController:UIExamsTVC animated:NO];
Compile error - Unexpected Interface name
How can I do this?

If you want to go back then you don't want to push anything new...that's just adds to the existing stack. If you got to the UITestVC through a push, you want a "pop" in order to go back. If you got there by presenting it modally, you want to "dismiss" it.
(What your actual error is telling you is that you can't use the name of a class when the method you're calling wants a reference to an object.)

Related

NSViewController StoryBoard Opening Window Error

I'm working on a program with several view-controllers, all of which I open at various instances as sheets, by controlling dragging from a button on one viewcontroller to another viewcontroller, and by selecting "Sheet". This has always worked, until now when recently tried to add another viewcontroller and connect it similarly. When I click the button to open it though, it crashes and throws the error: (NSButton): missing setter or instance variable. When I use the new button to open an old viewcontroller, it works, but when I use an old button to open a new viewcontroller, it doesn't. Anyone seen this before?
Turns out I wasn't specifying which viewController the data needed to be sent to so I made an if statement saying, "If this view controller, then" and "else" etc. which ended up working.

SWRevealViewController - know which ViewController is displayed

I am using the SWRevealViewController plugin (https://github.com/John-Lluch/SWRevealViewController) to have drawer-like transitions in my iOS app.
I added a panGestureRecognizer to my view to allow the user to drag the right ViewController to hide the left VC:
[self.view addGestureRecognizer: self.revealViewController.panGestureRecognizer];
Now i'd like to detect when the right VC has been dragged to trigger an animation, so basically I just want to find a way to automatically know which VC is displayed.
So far I have tried to bind an event to self.revealViewController.panGestureRecognizer with this code:
[self.revealViewController.panGestureRecognizer addTarget:self action:#selector(PanGestureEnded:)];
And then do this:
-(void)PanGestureEnded:(UIPanGestureRecognizer *)gesture{
if (gesture.state==UIGestureRecognizerStateEnded) {
//some code here
}
}
But my app always crashes and I gest a exc_bad_access error. So I enabled NSZombies and I get the following error message:
-[TabBarViewController PanGestureEnded:]: message sent to deallocated instance 0xc1ad890
Does anyone have an idea how to fix this?
Many thanks
I just encountered the same error today when trying to bind an action to self.revealViewController.panGestureRecognizer also.
I cannot fix the error. Instead, I set the current controller as the delegate of revealViewController, and call the delegate method:
- (void)revealControllerPanGestureBegan:(SWRevealViewController *)revealController
and perform my action in the above method.
Hope this help.
I've faced the same issue recently.
I was able to solve it by updating SWRevealViewController project to its latest release and instead of using the segue connection as "reveal view controller" (which is now deprecated) I'm using "reveal view controller push controller".

iPhone [self performseguewithidentifier... ] is not showing the new view controller

I have been all over stackoverflow and all over Google and I cannot seem to figure this one out. Here's my scenario:
I have my app's "main screen" where the user first makes decisions about what they're going to do. The app works off of a CoreData database which is created by "importing" XML files. The user can choose to open an XML file attached to an email in my application, which automatically triggers my main screen to show up and run the import of the file.
I can get this far without any issues. In my storyboard, I have a segue called ParseSegue from my main screen to a view controller which will handle the parsing and give the user some status information.
When the main screen is called via the email app, the main screen automatically calls
[self performSegueWithIdentifier:#"ParseSegue" sender:self];
I then check for this segue name in prepareForSegue and it's a valid name. This is where I assign the file URL to the parser controller so that it can parse the correct file.
The problem is that the segue never actually happens. The prepareForSegue method gets called, the name "ParseSegue" can be checked against and is valid, but the segue itself simply does not happen. If I add a button to the main screen and tell it to perform the segue within the storyboard, it works fine. But calling it programmatically seems to do nothing.
It turns out that I was looking in the wrong place entirely. My problem was that in my appDelegate, where the app reacts to the incoming URL, I was inadvertently creating a new instance of my storyboard and my main view controller. This was different than the one which was already active and may or may not have been on the screen.
The controller I was creating was never actually shown. I only noticed this because the log:
NSLog(#"Source: %#", [segue.sourceViewController description]);
would show different memory addresses for my test (the button push) and the import test. This led me to believe that I was, in fact, working with two different instances of the storyboard and the app's main view controller. Thanks to Paul for the suggestion of logging the destination and the source controllers.

How to see activities while performing actions?

In my iPhone app,
I am working with XIB file.
There is a segmented control,
But there is no IBAction associate with any field,
Whenever I am selecting or touching an segment which method from my code will be called ?
Can I trace or see it in the xcode.
Actually I am looking through some complex code and could not catch the methods by breakpoints ....
Like this Question of stackoverflow.
How to print or see method call stack in xcode?
If you want to see the target method you can right click the controller and see the the method associated with segmented control. If you want to add add some target method with segment controller then do this -
Right click the controller
drag the plus button of desired action(like valueChanged ) to .h file,one popup will come
enter the action name click connect
now go to .m file and write your logic in action
First of all, you do not associate any IBAction with the segmented control's "fields". You associate an IBAction with the control itself.
So, to get you started:
Create an IBAction like :
-(IBAction)segmentChanged:(UISegmentedControl *)sender;
Bind that action with the "Value Changed" event of your UISegmentedControl object
Now every time the segment changes, this method will be fired.
To get the selected index use:
uint selectedIndex = [sender selectedSegmentIndex];

Switch Views with button in iPhone App

Firstly, I am an iPhone programming noob (I know that's not very helpful). But I do speak english :).
I am making an app that is basically a soundboard, that is you press a button and it plays a sound effect.
One thing I wanted to add was a view which came up when a sound was playing, that said something like "A sound is currently being played, please tap anywhere to stop". The way I did this was take a screenshot of the normal screen, put a transparent black square over it in Microsoft Word (I know, great graphics program, right?) and use that. It looks fine.
I was wondering how to make it so that when you press a button to play the sound, not only does it play the sound, but it also switches views to the second view described above. Then, if the person touched the screen in the second view, it would switch back to the first view, and stop playing (I assume the best way to do this would be to have some kind of 'stop playing" method in the "viewDidLoad" section of the first view).
I would very much appreciate it if someone could tell me how to make an action which is called when a button is pushed, that switches views. I don't need any fancy navigation bar staying up or whatever, I just need it to switch views.
Also, my application is a view based application, and I currently have the following files:
Classes:
(appname)appdelegate (.h & .m),
(appname)viewcontroller (.h & .m), (my main window)
playingController (.h & .m), (my second window)
Resources:
(appname)viewcontroller.xib (main window IB file)
playing.nib (second window IB file)
mainwindow.nib (no Idea what this does, don't really care).
I think that these will work for the app, but I'm probably totally wrong. Please tell me if I need additional files, or if I need to rename these files.
Thanks a lot,
Luke
Try placing an invisible button over the entire view to get back to the first view
to get to any screen use something like this:
SecondScreen *second = [[SecondScreen alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
Steps:
1 Go to interface builder (double click .xib file)
2 Drag a UIButton on screen
3 Go to code
4 Go to .h file and write
-(IBAction) switchViews:(id)sender;
5 GO to .m file and type in
-(IBAction) switchViews:(id)sender
{
SecondScreen *second = [[SecondScreen alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
}
6 In interface builder, click the button, Hold CONTROL and Drag all the way (a line shows) to the FileOwner.
7 Choose switchViews method from list
gl
You need to create a new UIView, controlled by a UIViewController and presented with presentModalViewController
You need a UIButton, which can be set up either programatically or within IB that will call presentModalViewController
Once your new view is visible, you can set it up however you wish in terms of your 'Stop Playing' action. To remove it, dismissModalViewController is what you're looking for.
http://developer.apple.com/library/ios/documentation/uikit/reference/UIView_Class/
http://developer.apple.com/library/ios/documentation/uikit/reference/UIButton_Class/
http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/