I want to navigate from subview to another view.i have written the code but it is navigating from this view.please help me in solving this problem.
NSLog(#"selected tag:%d",[sender tag]);
UserViewController *uViewController=[[UserViewController alloc] initWithNibName:#"UserViewController" bundle:nil];
uViewController.usersArray=self.usersArray;
uViewController.accessingIndex=[sender tag];
self.userViewController=uViewController;
[self.navigationController pushViewController:self.userViewController animated:YES];
[uViewController release];
You can use this method to show a view
[self presentModalViewController:uViewController animated:YES]
To close it use:
[self dismissModalViewControllerAnimated:yes]
Related
I have this function in an IBAction button:
I start off with a table with a button, when that button is pressed this takes place:
TabBarController *v = [[TabBarController alloc]
initWithNibName:#"TabBarController" bundle:nil];
[self.navigationController pushViewController: v animated:YES];
[v release];
On the second view there is another button which when pressed does this:
NSArray *array = [self.navigationController viewControllers];
[self.navigationController
popToViewController:[array objectAtIndex:1] animated:YES];
This causes the app to crash, and at index 0 it does nothing. Is this because the second page is not a UITable like the first?
I want to be able to move from UITable view to UIView back and forth, should I use addSubview instead? I need the first view to have a navbar but the second shouldn't.
I think the problem is that [array objectAtIndex:1] is your current ViewController, so popping to the current view controller might be the reason of your crash (did not try it though)
So why don't you do:
[self.navigationController popViewControllerAnimated:YES];
simply add the following line in button code and it will work fine
[self.navigationController popViewControllerAnimated:YES];
I founded that the problem is the place where I'm calling the showNextView. I have another interface webService where i communicate with server and parse xml. When the parsing is finished with method parserDidEndDocument I'm calling the delegate method where is changed the view and show modal view. But when i call all that methods it will return to endDocument and xmlParseChunk and so on. It looks like the parserDidEndDocument is not realy the last method and somehow it mess with navigationcontroler. When i call the method for showig nextView with button it works.
The code which is working on button. In delegate method called from parserDidEndDocument is not working correct.
-(void)showNextView
{
UIViewController *nextView = [self.storyboard instantiateViewControllerWithIdentifier:#"vcTrabantInfo"];
[[nextView navigationController] setNavigationBarHidden:NO animated:NO];
[[self navigationController] pushViewController:nextView animated:YES];
UIViewController *picker = [[UIViewController alloc] init];
[picker setModalPresentationStyle:UIModalPresentationFormSheet];
[[self navigationController] presentModalViewController:picker animated:YES];
}
As usualy the problem was between keyboard and seat. The problem was that my modal views haven't been dismissed before i call another modal view :). So keep in mind that all is done in viewDidDisappear.
I used button action to to pop sub view sing below code;
- (IBAction)pickerUpBtn:(id)sender {
PickerPopUpController *screen = [[PickerPopUpController alloc]initWithNibName:#"PickerPopUpController" bundle:Nil];
[self.view addSubview:screen.view];
[self presentModalViewController:screen animated:YES];
}
after i need to go previous window; So i used another button action for it and add bellow code inside action
PickerViewController *screen = [[PickerViewController alloc]initWithNibName:#"PickerViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:screen animated:YES];
But It does not navigate to previous view . How could i do it ??
to go back,
do
[self dismissModalViewControllerAnimated:YES]
You need to put only that single code in the Button action..No need of making object of parentViewController.
ie,
-(IBAction)btnaction:(id)sender{
[self dismissModalViewControllerAnimated:YES];
}
You need to add cancel and done for your ViewController which is present modely to come back to parent view Controller.
After implementing the Cancel button, you have to dismiss your viewcontroller in the action function of Cancel button using the dismissModalViewControllerAnimated function
[self dismissModalViewControllerAnimated:YES];
For push view controller, you can do like below,
PickerViewController *screen = [[PickerViewController alloc]initWithNibName:#"PickerViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:screen animated:YES];
Then for go back, you have to add one button in "Screen" view controller and it's click event you have to write below code,
[self.navigationController popViewControllerAnimated:YES];
Hope, it would be helpful.
Let me know in case of any difficulty.
If you are using the method "presentmodelviewcontroller" then you have to write below line in button click.
[self dismissModalViewControllerAnimated:YES];
let me explain you my problem:
I have an UIViewController with 2 UIViews.
I have a button in one of my UIView and i call a methode from my UIViewController.
[controller actionMainSettings];
And this is the methode:
-(void)actionMainSettings{
MainSettings *mainController = [[MainSettings alloc] initWithNibName:#"MainSettings" bundle:nil];
[self.navigationController pushViewController:mainController animated:YES];
[[self navigationController] setNavigationBarHidden:YES animated:NO];
[mainController release];
}
MainSettings is an UIVewController...
and nothing happen...
When i put my button in my UIVIewController ([self.view addSubview:buttonSettings];) it's ok but i want to put it in another UIView.
Can someone explain me what happen?
thx
I am not very sure about this but you could try super.navigationController instead of self.
Also, from the look of your code, I would assume it's a settings view. I would recommend that you use [self presentModalView:yourView animated:YES]. You can look at the UIView documentation for a range of animations.
Okay, working on a transition between a view with a tabbar and another view which is to be an information/about view. I have the code to transition from the view with tabbar and to transition back to previous view, but during the transition back I lose the tabbar at the bottom. Not sure exactly how to approach this with the tabbar in the MainWindow.xib
E.g.:
(IBAction)backButtonPressed:(id)sender
{
TablesViewController *tvc = [[TablesViewController alloc] initWithNibName:#"TablesView" bundle:nil];
tvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:tvc animated:YES];
[tvc release];
}
Thanks,
np
Try presenting the modal transition from the containing instance of UITabBarController and not the UIViewController the action was triggered from.
- (IBAction)backButtonPressed:(id)sender
{
TablesViewController *tvc = [[TablesViewController alloc] initWithNibName:#"TablesView" bundle:nil;
tvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.tabBarController presentModalViewController:tvc animated:YES];
[tvc release];
}
I had the exact same problem, did a ugly solution:
- (IBAction)backButtonPressed:(id)sender {
[self.navigationController dismissModalViewControllerAnimated:YES];
}