Switching between view controllers without using navigation controller stack - xcode

i am creating my first app.i have multiple view controller stack in my app. i want to switch view controllers, so i am using this method:
wallViewController *dvc = [[wallViewController alloc] initWithNibName:#"wallViewController" bundle:nil];
dvc.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:dvc animated:YES];
[dvc release];
its working fine. but its reloading view controller,like its calling viewdidload each time,but i want to show the previous state of parent view controller as in navigation controller.Please help me.

Related

NSFetchedResultsController running after performing push on UINavigationController

I am using an NSFetchedResultsController with my tableview inside of a UINavigationControler. When an item is tapped on the tableview I perform a 'push' and pass a specific entity in the prepareForSegue in order to show more detailed data about that record.
In the detail view controller the model can be edited. There appears to be a lot of lag when I change the model. And I noticed that the tableView:cellforRowAtIndexPath: on the previous view controller is being called.
I've tried using performSelectorInBackground: but doesn't seem to help much.
Once push a view controller, isn't the view controller below not supposed to run? Has anyone been able to overcome this lag issue?
Thank you
I actually ran into this tonight and solved it by adding a new bool property on my view controller to store when my VC is visible.
#property (nonatomic, assign, getter = isVisble) BOOL visible;
Then I check at the top of FRC delegate methods if the view is visible or not.
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
if (! self.isVisble) {
return;
}
[tableView beginUpdates];
}
This seems to help stuttering and performance when the VC with the FRC has been pushed behind other VCs.

iPad Popup Form

I have iPad application with main view controller with a navigation bar at the top. I want to create a signIn button on navigation bar, which should open a popupview with username, password, one additional field and a login button. Clicking login button will close the popover and pass the information from text field back to main view controller.
I have been trying to find something like this on web , but no luck.
Does anyone knows a way to do this ?
You should take a look at UIPopoverController
This is how you initialize and show it:
UIPopoverController *myPopover = [[UIPopoverController alloc] initWithContentViewController:myForm];
[myPopover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionsAny animated:YES];
To get data back from myForm you probably want to use delegation.
myForm.delegate = self; //before presenting de popover

NSString editing by many View Controllers?

I want to print a NSString in my TextView in the mainViewController. But this command should come from a second ViewController. I declared a string in my mainViewController.h but I need this string in secondViewController.m! (The text should be printed in mainViewController). When I want to access to this string, it says Xcode does not know this variable. How can i create a string/variable, which I can edit and print from all of my ViewControllers(xib!)?
It sounds like you want to share a model between two view controllers. This is the correct MVC approach so that all that is required is for one of the view controller to change the value in the model and all the other view controllers will be notified and can update their respective views:
Please look at this excellent article on how this should be implemented.
just declare that NSString variable in AppDelegate & access in any ViewController through the sharedApplication method .in your case assign value to it in secondViewController & access that value in mainViewController
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSLOg(#"Nsstring value=%#",appDelegate.stringVariable);
assigning value:appDelegate.stringVariable=#"fromSecondViewController");

Xcode - Access one view controller from multiple view controllers

I have created an app which in total has 4 view controllers. 2 of these are pages that contain content with an (i) button in the top corner which links to an "about" section of the app. Currently I have 2 separate view controllers displaying the same thing (the about page) as I can't get the two view controllers to link to a single one when I click the button on each respectively.
Is there a way for two view controllers to access one view controller without me having to create a different about page for each one?
Thanks heaps
First you should set the button's target:
exampleButton addTarget:self action:#selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside;
Then, in the button's method:
-(void)buttonAction:(id)sender
{
AboutViewController *aboutViewController = [[AboutViewController alloc] init];
[self.navigationController pushViewController:aboutViewController animated:YES];
}
Don't forget to add the about view controller's header file
#import "AboutViewController.h"
If you use storyboard, you should change the button's action method with
-(void)buttonAction:(id)sender
{
[self.navigationController performSegueWithIdentifier:#"aboutSegueIdentifier" sender:sender];
}

Dismiss Parent View Controller iOS 5

Im going to a new view using the following code:
UIStoryboard *storyboard = self.storyboard;
finishViewController *finished = [storyboard instantiateViewControllerWithIdentifier:#"finishViewController"];
[self presentViewController:finished animated:NO completion:nil];
Once the new view is loaded the previous view controller is still functioning behind it. Is there a way I can erase it from memory?
Ive tried:
[self.presentingViewController dismissModalViewControllerAnimated:YES];
and
[self.parentViewController dismissModalViewControllerAnimated:YES];
I thought this would be pretty straight forward. T
Thanks
You're presenting a modal view from the parent view controller.
It sounds like what you really want to do is push or segue the finished view controller from the parent view controller.
If you are determined to dismiss / erase the parent view controller, why not first pop the parent view controller and then push/present the finished view controller.
Try using [finished makeKeyAndVisible] it'll make your new controller the only controller.
This can't be done. If you dismiss the parent you'll dismiss both of them.

Resources