I have created an application that if the page cannot load, it gives an error message. However, after that, it just shows a blank white screen. How can I edit the code so that it will automatically go to the previous view?
Call popViewControllerAnimated:(BOOL)animated method of the UINavigationController if page cannot load.
My guess that what would work for you would be after the alert do something like:
if(butttonIndex == 1){
Previous_View *next=[[Previous_View alloc] initWithNibName:#"Previous_View" bundle:nil];
[self.navigationController pushViewController:next animated:YES];
}
You can do like this after your message:
[self.navigationController popViewControllerAnimated:YES];
or if you want to jump back to the root view:
[self.navigationController popToRootViewControllerAnimated:YES];
Related
I have a popover menulet and it's contentViewController is some NSViewController. Everything fine here. The problem that I have is that I really don't understand how to change the View. I wanna load another view, and this is what I tried:
popover = [[NextViewController alloc]initWithNibName:#"NextViewController" bundle:nil];
[self.view addSubview:[popover view]];
And this works, new view is shown - but if I click on any button on that view I get error: unrecognized selector sent to instance. Why am I getting this error? Why this new view is not responding?
Please help me understand what I need to do, how to change the view on NSPopover?
I've managed to solve my problem, It turn out to be quite easy:
[self.view setSubviews:[NSArray array]]; //remove all previous subviews
[self.view addSubview:[popover view]];
I've got a small project with two UIImageView-based nib files.
When the main view loads, it looks correct.
To switch between views, I'm using code like this (for example, this is to go to second view)
-(IBAction) secondClicked:(id)sender {
SecondViewController *second = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:main animated:NO];
[second release];
}
When the new view is shown, it's shifted sideways about 10% of screen. Using similar code to go back to main results in the main view being shown similarly offset.
I'm in landscape mode, if that makes a difference.
How can I display the views so they're correctly aligned?
Ok it makes sense now that I looked more carefully. Why are you presening a view controller modally when you wish to go back? How did you showed this viewController initially? If it was through a navigation controller you should pop the view
[self.navigationController popViewControllerAnimated:YES];
If it was presented modally you should just dismiss it!
[self dismissViewControllerAnimated:YES];
I need help in following scenario.
I am building an app that displays tableview. If the user tap an entry it goes to the detailed screen. In the detail screen, I have a button to delete this entry. It deletes the entry from the data source and dismiss the modal.
But after dismissing the modal, table view data is not refreshing.
If I go back to parent view controller and then again come back to child screen, it refreshes the count.
I read few similar posts and found the following solution.
[tableview reloadData];
Or
[self.tableView reloadData];
In - (void)viewDidAppear:(BOOL)animated of child screen.
But its not refreshing the table view.
Please help.
For completeness, the full implementation would be:
- (void)viewWillAppear:(BOOL)animated
{
// Do stuff like reload the tableview data...
[self.tableView reloadData];
}
If it's not working you have a problem elsewhere in your code.
If the tableview is in the parent viewcontroller, I suggest that placing reloadData: method at viewWillAppear: of the parent.
(void)viewWillAppear:(BOOL)animated
{
[self.tableView reloadData];
}
I'm sure that the method will be called when the detailed viewcontroller dismissed.
Go through this code:
- (void)viewWillAppear:(BOOL)animated
{
[self.tableView reloadData];
}
I want to create a window that pops up like in the email app when you hit New Email.
Does anyone has a good tutorial or sample code of how to do this?
This is the screen I want:
Basically it looks like a view controller shown modally with modalPresentationStyle set to UIModalPresentationPageSheet:
SomeViewController *vc = [[SomeViewController alloc]
initWithNibName:#"SomeViewController" bundle:nil];
vc.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentModalViewController:vc animated:YES];
[vc release];
On the view controller, at the top is a UIToolbar and the content underneath can be shown in several ways including a UITableView.
In portrait, the modal view will be the full width of the screen.
It's a modal view controller with style as pagesheet.
You have to present whatever you want as a modal view controller after setting it's modal style.
My Application have navigation controller and table views. When the back button is clicked and the view is popped out from controller stack, i noticed that the table events are not executed (eg: cellForRowIndexPath). Is there anyway that these events are execueted when view is popped out.
This is the code i use for pushing the view into controller stack.
MyViewController *obj = [[MyViewController alloc] initWithNibName:#"MyViewController" bundle:nil];
[self.navigationController pushViewController:obj animated:YES];
[obj release];
Regards
Sandy
You can use the ViewWillAppear and ViewWillDisappear methods.
what you want to do is put a call to
[theTable reloadData];
which initiates all of the calls that you wanted.
This call should be placed where you want the table to reload - either on appear or disappear.
Good Luck !