i'm trying to implement a modal presentation of my settingsViewController. This works fine, but when it is presented it is not showing the tableView which is in the SettingsViewController. It just show a grey background and navigation bar. How come it is not showing my tableView inside the SettingsViewController?
SettingsViewController *settingController = [[SettingsViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:settingController];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:NULL];
Related
I wanted to Push New View Controller with Transparent Background on top of one View Controller which is already shown. I know How to PRESENT but I wanted to PUSH new View Controller.
UIViewController *controller = [[UIViewController alloc] init];
self.definesPresentationContext = YES;
controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:controller animated:YES completion:^{}];
You need to give memory to your ViewController and set to RootController of UINavigationController. After that, you can push it from your current controller...
UIViewController *yourViewController = [[UIViewController alloc] init];
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:yourViewController];
[self presentViewController:navigationController1 animated:YES completion:nil];
I have a view controller I am presenting modally. I want the status bar color to match the navigation bar color.
I have set UIViewControllerBasedStatusBarAppearance to YES because I don't want this change across the entire application.
I am setting self.navigationController.navigationBar.barTintColor but this is only changing the navigation bar color. The status bar remains a lighter color.
I have tried various combinations of setNeedsStatusBarAppearanceUpdate and preferredStatusBarStyle but none have any effect.
View controller is launched like so:
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:searchController];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
My steps are below, check where you go wrong:
Create 2 view controller like below, you can let vc1 embed in a navigation controller:
In the vc1, you drag a action of the button:
Code is below:
- (IBAction)clickAction:(UIButton *)sender {
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
ViewController2 *searchController = [sb instantiateViewControllerWithIdentifier:#"ViewController2"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:searchController];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
}
Then in the vc2, you set the title:
I am trying to present a UITableViewController modally on one of my view controllers which is further embedded in a UITabBarController. The code I am using is -
ContactTableViewController *contactsVC=[self.storyboard instantiateViewControllerWithIdentifier:#"contact"];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:contactsVC];
navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
contactsVC.myDelegate = self;
[self.navigationController presentViewController:navController animated:YES completion:nil];
The view is presented just fine the first time I do it but when I navigate to this view again in my app, the view being presented is completely blank.. No navigation bar buttons, no title, nothing..
Can't figure out a reason... Any help is very much appreciated!
UPDATE:
HomeViewController *vc = [[HomeViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
This what I do to navigate to that view again while unhiding the tab bar. Home View is the view that presents the Contacts Table View modally.
I wrote my code like this
- (void)menuButtonClick:(id)sender{
ViewController *test = [[ViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:test];
[self presentViewController:navController animated:YES completion:nil];
}
But I discover that the view goes transparent when moving into the screen. The view turns to white as it should be after the animation.
like this.
If the GIF is not playing, please open it in a new tab.
Could you please tell me how to solve this problem?
I'm just trying a really simple example here as I start to delve into iOS development for ipad.
I'm creating a split view and immediately trying to present a modal form sheet.
Should be really basic.
With what I've tried I get what behaves like a page sheet instead.
In landscape I can see the split view beneath but I don't see the top of my modal view (the tool bar is hidden but is in view in portrait).
I would expect to just grey out the split view beneath a 540x620 modal dialog. I should see the split view beneath my modal in both portrait and landscape like all the nice form sheet dialogs in the Cheddar app for example.
I must be doing something wrong here but all the examples I've read and same within the Cheddar app are doing pretty much what I outline below.
In the app delegate:
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:#"MasterViewController" bundle:nil];
UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:#"DetailViewController" bundle:nil];
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
masterViewController.detailViewController = detailViewController;
self.splitViewController = [[UISplitViewController alloc] init];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = #[masterNavigationController, detailNavigationController];
self.window.rootViewController = self.splitViewController;
[self.window addSubview:self.splitViewController.view];
ModalViewController *modalView = [[ModalViewController alloc] initWithNibName:#"ModalViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:modalView];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
[self.splitViewController presentViewController:navController animated:NO completion:nil];
The app delegate is way too soon. You have no interface yet, so you can't coherently do any presenting of any view controller.
So, first thing, move all your modalView code to the viewDidAppear: of your detailViewController.