UIModalPresentationFormSheet on iPad - hide status bar - objective-c

Any idea why it's not possible to hide status bar when modal controller is presented as UIModalPresentationFormSheet on iPad?
override preferedStatusBarHidden doesn't work

You can hide the navigation bar throw the navigational controller.
For example use:
[infoViewNavController setNavigationBarHidden:YES animated:NO];
Where infoViewNavController is the Navigation Controller that will hold your viewController for Modal Presentation.
Assuming you are calling it like this:
UINavigationController *infoViewNavController =
[[UINavigationController alloc] initWithRootViewController:viewControllerToShow];
infoViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;
infoViewNavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[infoViewNavController setNavigationBarHidden:YES animated:NO];
self.navigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
self.navigationController .modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentViewController:infoViewNavController animated:YES completion:nil];

Related

UIPopoverPresentationController can not be dismissed on iPhone

I'm implementing a CABTMIDICentralViewController (Apple's pre-fab BTLE MIDI configuration panel). The code below is Apple's sample code - unmodified.
It works perfectly on iPad, but on iPhone/iPod it results in an uncloseable fullscreen view. The code clearly creates a Done button, but it isn't shown on the devices.
The common answer is "you need a UINavigationController", but there is one being made in this code. So I'm not sure what else is missing?
- (void)doneAction:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)configureCentral:(id)sender
{
CABTMIDICentralViewController *viewController [CABTMIDICentralViewController new];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
// this will present a view controller as a popover in iPad and modal VC on iPhone
viewController.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:#selector(doneAction:)];
navController.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popC = navController.popoverPresentationController;
popC.permittedArrowDirections = UIPopoverArrowDirectionAny;
popC.sourceRect = [sender frame];
UIButton *button = (UIButton *)sender;
popC.sourceView = button.superview;
[self presentViewController:navController animated:YES completion:nil];
}
You will have to implement the UIPopoverPresentationControllerDelegate to view popovers in iPhones. By default it will be presented in the style of an already presented view controller.
Add this piece of code to present the controller as popover
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(nonnull UITraitCollection *)traitCollection {
return UIModalPresentationNone;
}

Objective-C Modal View Controller with Transparent Background

I wanted to create a modal View Controller that would have a transparent background but when I tried setting the alpha of the background to 0.5 it just made the view behind it completely black. This is because the background views are being removed after the transition.
self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
[self setModalPresentationStyle:UIModalPresentationFullScreen];
[self setDefinesPresentationContext:YES];
Then presenting View Controller Code
SecondViewController *alertView = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
[self presentViewController:alertView animated:YES completion:nil];
please look at the link
image/linke.gif
Try this code in the action of the button in the firstViewController to change the view controller and present a new class secondViewController
secondViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:#"secondViewController"];
VC.view.backgroundColor=[UIColor colorWithWhite:0 alpha:0.1f];
VC.modalPresentationStyle=UIModalPresentationOverCurrentContext;
[self presentViewController:VC animated:NO completion:nil];

exit from TabBarController to ViewController

I have 2 viewcontrollers in a TabBarController, in 2nd ViewController I have a button which on click should take me to ThanksViewController with out Tabs anymore!!
Please check my code below:
//AppDelegate.m
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:_viewController];
self.window.rootViewController = nav;
//ViewController.m
tab=[[UITabBarController alloc]init];
tab.delegate=self;
oneViewController=[[OneViewController alloc]init];
UINavigationController *oneNav=[[UINavigationController alloc]initWithRootViewController:oneViewController];
oneNav.title=#"One";
twoViewController=[[TwoViewController alloc]init];
UINavigationController *twoNav=[[UINavigationController alloc]initWithRootViewController:twoViewController];
twoNav.title=#"Two";
views=[[NSMutableArray alloc]initWithObjects:oneNav, twoNav, nil];
tab.viewControllers=views;
[tab.view setFrame:CGRectMake(0, 0, 1024, 748)];
[self.view addSubview:tab.view];
In my TwoViewController (tab 2) I've a Button 'OK' which on click should take me to ThanksViewController, for that I've written the following code:
//TwoViewController.m
-(void)OK
{
ThanksViewController *thanksViewController=[[ThanksViewController alloc]init];
[self.navigationController pushViewController:thanksViewController animated:YES];
}
My problem is I want to exit from TabBarController and move on to the ThanksViewController(without TabBarController at the bottom) but in this case I'm getting the ThanksViewController in the TabBarController itself in place of the TwoViewController.
Can someone please suggest me in this case, thanks in advance.
After push ThanksViewController do you want to be possible to go back and present TabBarController again?
If so, use modal, like this:
ThanksViewController *view = [[ThanksViewController alloc] init];
UINavigationController *navThanks = [[UINavigationController alloc] initWithRootViewController:view];
[navThanks setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:navThanks animated:YES];
[self.view setHidden:YES];

Navigation bar doesn't appear in uiviewtable in popupovercontrol

I have PopupoverControl and this popup has UIViewtablecontrol and one of UITable control should navigate to another UIViewtablecontrol but it doesn't navigate this is the code in selection in first uitableview:
OpenFileViewController *openfileview = [[OpenFileViewController alloc] initWithNibName:#"OpenFileViewController" bundle:nil v_files:[self GetFiles] v_ui:parentview];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:openfileview];
[self.navigationController presentModalViewController:navController animated:YES];
in .xib file in both uiviewtable I enabled Top Bar with Navigation Bar but it doesn't appear why?
No need for the new navController, try this instead:
[self.navigationController pushViewController:openfileview animated:YES];
Edit:
The root view controller of the popover should be a UINavigationController object, so try this when you're creating the popover:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: optionw];
UIPopoverController *optioandiaglog= [[UIPopoverController alloc] initWithContentViewController:navController];

ModalView presented from MasterViewController is no longer Full Screen in iOS 5.1

I have a Master/Detail application and have a button on the top right of the MasterViewController in the split view that loads an "Info" view controller using a modal view:
When the button is clicked, the view is loaded, and populates the entire screen in iOS 5.0 and below (this is the behavior that I want):
- (IBAction)showAppInfo:(id)sender
{
InfoViewController *infoViewController = [[InfoViewController alloc]
initWithNibName:#"InfoViewController" bundle:nil];
infoViewController.delegate = self;
[self presentModalViewController: infoViewController animated: YES];
}
However, when I run this in the iOS 5.1 simulator, it no longer populates the entire iPad screen, and only populates what's inside the Master View:
What can I do to make this InfoViewController populate the entire screen in iOS 5.1 as it did before?
I assume you are using UIPopoverController, try this
InfoViewController *infoViewController = [[InfoViewController alloc]
initWithNibName:#"InfoViewController" bundle:nil];
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:infoViewController];
popoverController.popoverContentSize = CGSizeMake(500.0, 583.0);
popoverController.delegate = self;
[popoverController presentPopoverFromRect:sender.bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];