We have UITableViewController in which we are giving table edit functionality like attached screenshot. And we want to show/hide bottom toolbar for bar button items.
for edit we are using below code.
[self.tableView setEditing:YES animated:false];
editButton.title = #"Cancel";
[self.navigationController setToolbarHidden:NO animated:YES];
After this code we are getting toolbar like the given image (two toolbars). How to remove white toolbar?
Thanks
Edit:
We are getting this issue when we are doing pushViewController:
TransactionsListViewController *callTransactionsListViewController=[[TransactionsListViewController alloc]initWithStyle:UITableViewStylePlain];
[self.navigationController pushViewController:callTransactionsListViewController animated:YES];
In presentViewController we are not getting above issue:
TransactionsListViewController *callTransactionsListViewController=[[TransactionsListViewController alloc]initWithStyle:UITableViewStylePlain];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:callTransactionsListViewController];
[self presentViewController:navController animated:YES completion:nil];
In ViewDidLoad
[self.tableView setAllowsMultipleSelectionDuringEditing:YES];
[self.tableView setAllowsMultipleSelection:YES];
TableView Edit on button tap:
-(IBAction)btEdit:(id)sender{
if (self.tableView.editing)
{
[self.tableView setEditing:NO animated:false];
editButton.title = #"Edit";
[self.navigationController setToolbarHidden:YES animated:YES];
}
else{
[self.tableView setEditing:YES animated:false];
editButton.title = #"Cancel";
[self.navigationController setToolbarHidden:NO animated:YES];
} }
The white toolbar is not actually a toolbar. I think that when you show the toolbar for some reason table view gets twice offset from the bottom. It may be system issue or code in your application. It would be helpful if you could specify view and view controller hierarchy on this screen and any custom layout you apply to table view.
Related
2 Controllers
PageviewController
1)
- (void)applicationDidFinishLaunching:(UIApplication *)application
[self.window setRootViewController:navigationController];
On bottom toolbar button click in view pushing second UINavigationController:
[self.navigationController pushViewController:cnController animated:YES];
Loading of UIPageViewController in UINNavigationController:
#interface SwipeBetweenViewControllers : UINavigationController <UIPageViewControllerDelegate,UIPageViewControllerDataSource,UIScrollViewDelegate>
On bottom toolbar button click in view:
SampleViewController *viewController = [[SampleViewController alloc] initWithStyle:UITableViewStyleGrouped];
viewController.model = settingsModel;
viewController.navigationItem.title = #"Settings";
[viewController willMoveToParentViewController:self];
// [[self navigationController] setNavigationBarHidden:YES animated:YES];
[self.view addSubview:viewController.view];
[self addChildViewController: viewController];
[viewController didMoveToParentViewController:self];
[self.navigationController pushViewController:viewController animated:YES];
It shows 2 navigation controllers. I need to hide the top one when I issue following:
[[self navigationController] setNavigationBarHidden:YES animated:YES];
It hides UIPageviewcontroller navigation and go back to original view. I also tried:
NSMutableArray *allControllers = [self.navigationController.viewControllers mutableCopy];
[allControllers removeObjectAtIndex:allControllers.count -1];
and also
for (UIViewController *controller in self.navigationController.viewControllers)
{
if ([controller isKindOfClass:[SampleViewController class]])
{
[[self navigationController] setNavigationBarHidden:YES animated:YES];
}
}
How to hide specific original navigation controller?
Thanks for all your help.
I was able to solve this.
Actually, I was pushing viewController to top one #1 navigationcontroller, whereas it was to pushed into bottom one #2 navigationcontroller.
And wrapping #2 navigationcontroller in a containerUIviewcontroller set right navigation.
Thanks
I am trying to show navigation controller when i present PresentViewController for navigate a screen. I solved this problem, but i faced another problem. Problem is when i push to a screen that time back button is visible on next screen with navigation controller. But when i am trying to PresentViewController, that time navigation bar is visible but not back button.
Here is my code:
- (IBAction)clickMeAction:(id)sender
{
ViewController1 *viewcontrol = [self.storyboard instantiateViewControllerWithIdentifier:#"ViewID"];
//[self.navigationController pushViewController:viewcontrol animated:YES]; // this is for push to viewcontroller
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewcontrol];
[self presentViewController:navigationController animated:YES completion:nil]; // This is for modalviewcontroller
}
Here is my output:
with push:
with modal:
Please help me.
Method 1:
[navigationController presentViewController:navigationController animated:YES completion:^{
[navigationController setNavigationBarHidden:YES animated:NO];
}];
Method 2: in presentViewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
I created a UITableViewController inside of a container in a UIViewController.
Everything works fine until I click on a cell in order to view a user's information.
When I click the row is supposed to go to a view that contains tabs, but it's not doing this (it stays on the page of the table).
I know it calls the function below since I put an NSLog in there and when I click a row it gets displayed.
Can someone please help me? Thank you!
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UINavigationController *tabController = [self.storyboard instantiateViewControllerWithIdentifier:#"TabNav"];
tabController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController pushViewController:tabController animated:YES];
}
Before you call:
[self.navigationController pushViewController:tabController animated:YES];
You have to add the UINavigationController - tabController to the view hierarchy.
// EXTENDED
Try this,:
UINavigationController *tabController = [self.storyboard instantiateViewControllerWithIdentifier:#"TabNav"];
[tabController willMoveToParentViewController:self];
//try wit this line if this will not work
//tabController.view.frame = self.view.bounds;
[self.view addSubview:tabController.view];
[self addChildViewController:tabController];
[tabController didMoveToParentViewController:self];
[self.navigationController pushViewController:tabController animated:YES];
I found out the problem! For some strange reason I had to do change these lines:
UINavigationController *tabController = [self.storyboard instantiateViewControllerWithIdentifier:#"TabNav"];
tabController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController pushViewController:tabController animated:YES];
To these lines:
UIViewController *viewController = [[UIStoryboard storyboardWithName:#"Main" bundle:nil]instantiateViewControllerWithIdentifier:#"TabNav"];
[self presentViewController:viewController animated:YES completion:nil];
In other words, it wasn't recognizing self.storyboard... Anyways, thanks for your help!
I have a screen tutorial for my app. I have a UIPageViewController setup to manage 3 View Controllers. Once you get to the last view on the tutorial you press a "done" button and the tutorial is supposed to go away.
I can't seem to find a way to pop/dismiss the tutorial. I have tried the following:
[self dismissViewControllerAnimated:YES completion:nil];
[self.navigationController popViewControllerAnimated:YES];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
Any ideas would be appreciated.
The View Controllers being managed are subviews of UIViewController if that's of any help.
EDIT
This is how I set up the views:
In my UIPageViewController I have the following:
-(void)viewDidLoad{
[self.pageController setViewControllers:#[tutorialPages[0]]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];
}
- (void)setupContentViews{
ScreenTutorial_1ViewController *screenTutorial1 = [[ScreenTutorial_1ViewController alloc] initWithNibName:#"ScreenTutorial_1ViewController" bundle:nil];
ScreenTutorial_2ViewController *screenTutorial2 = [[ScreenTutorial_2ViewController alloc] initWithNibName:#"ScreenTutorial_2ViewController" bundle:nil];
ScreenTutorial_3ViewController *screenTutorial3 = [[ScreenTutorial_3ViewController alloc] initWithNibName:#"ScreenTutorial_3ViewController" bundle:nil];
tutorialPages = #[screenTutorial1, screenTutorial2, screenTutorial3];
NSLog(#"tutorPages = %#", tutorialPages);
}
First, I strongly recommend you using:
[[NSUserDefaults standardUserDefaults] setObject:#YES forKey:#"hasSeenTutorial"];
Secondly, how are you presenting your PageViewController? In order to dismiss it like you have, you need to use (from a UIViewController):
[self presentViewController:tutorial animated:YES completion:nil];
Where tutorial is your Tutorial View controller. This will slide it up across the screen (or you can not animate it), and then you can dismiss it like you have.
Wild shot in the dark here, but I think you could reach your UIPageVieWController by calling self.parentViewController in your child controllers.
You could then either dismiss it (if it's modally presented) or pop it.
I just realized that I had 2 views in a xib file and the IBAction was connected to the wrong one. I've been copying and pasting buttons, labels...etc. On one of those pastes, I must have copied the pasted the entire view. I deleted it and used the following command which did dismiss the View:
[self dismissViewControllerAnimated:YES completion:nil];
I have a UITableView with a cell named 'Sunset'. Upon pressing the UITableViewCell, the view switches to 'infoView' which loads some text from a .txt file. When pressing the 'back' button, the view switches back to the UITableView but there's a problem. After loading the view, the UITabBar is gone! Since it is gone, it is impossible to go back to another view.
I have tried:
self.hidesBottomBarWhenPushed = NO;
Code:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cellSelected = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellTitle = cellSelected.textLabel.text;
if (cellTitle == #"Sunrise")
{ //Swap views
informationView *iv = [[informationView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:iv animated:YES];
}
}
Of course the tab bar doesn't show. You are presenting the second view modally. If you want to keep this implementation you are going to have to add a button or something on the second view that will perform
[self.navigationController dismissModalViewControllerAnimated:YES]; //Programatically dismiss the view controller
If you want to keep the tabBar and the navigation bar functionality, you should use
[self.navigationController pushViewController:iv animated:YES];
instead of
[self presentModalViewController:iv animated:YES];