Popup model view show black screen in rotated parent viewcontroller - ios

I have a ViewController, which contains a button. In start-up, I rotate the window by PI radius. In appplication:didFinishLanchingWithOptions function add follow codes:
[application setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown];
self.window.transform=CGAffineTransformMakeRotation(M_PI);
self.window.bounds = CGRectMake(0, 0, 320, 480);
I hope click the button to popup a model view (by presentViewController function), but I only see a black screen. The button click event:
- (void)btnAction:(id)sender {
UIViewController *vc = [self.storyboard instantiate...WithIdentifier:#"modal";
[self presentViewController:vc animated:YES completation:nil]; // unexpected behavior
// [self.navigattionController pushViewController:vc]; // expected behavior
}
By debug I know the modal view's center has some offset but I can not correct it. When I use push segue to replace it, it has right behavior.

When you start your application you see black screen or after clicking button to show your modal view.
that is called black popup screen.

Related

After hiding TabBar can't touch on the area behind the TabBar

I use a TabBarController on my app, in one of the main views (aViewController) i push another controller (bViewController), and hide the TabBar using self.tabBarController.tabBar.hidden=YES;
bViewController have a button at the same place where the tabBar was, and it doesn't catch the touch event.
I have tried placing the button in different places of bViewController, and the area where the tabBar was supposed to be is the only place where touch event is not detected.
I have tried using bViewController outside the tabBarController and it works fine.
Any help would be appreciated.
EDIT:
When i press a button on aViewController i call
self.tabBarController.tabBar.hidden=YES;
[self performSegueWithIdentifier:#"aViewToBView" sender:self];
aViewToBview is a push segue declared on storyboard
For some reason you cannot touch the views underneath the tab bar.
However, if you hide the tab bar and then add a subview to it, the view can then receive user interaction!
This worked for me:
// Create a button that is at the very bottom of the screen
CGFloat buttonHeight = 45.0f;
UIButton *finishButton = [[UIButton alloc] initWithFrame:CGRectMake(
0,
self.view.frame.size.height - self.tabBarController.tabBar.frame.size.height - buttonHeight,
self.view.frame.size.width,
buttonHeight)];
//...more initialization of the button...
//Here is our solution:
[self.tabBarController.view addSubview:finishButton];

A view is presented on the click of a button. As soon as i click on the button, the view moves at the left

In my project, i have a button which presents a viewController (transitionStyle is coverVertical and modalPresentationStyle is FormSheet). I want the view should be presented at the centre but on the click of the button, the view opens at the left and then when the keyboard is put down it moves at the centre. Can anyone tell me why? I have used viewController.view.superview.center = self.view.center;
Check out my presentingViewController code which i have put in the click of the button.
Try this, see if it works
viewcontroller.view.superview.frame = CGRectMake((self.view.centre.x-540)/2, (self.view.centre.y-650)/2, 540, 650);
I got the answer to my question. Instead of using
[self presentViewController:vcRevaluateInventory animated:YES completion:nil];
for presenting the view, just use
[self presentViewController:vcRevaluateInventory animated:YES completion:^{
vcRevaluateInventory.view.superview.bounds = vcRevaluateInventory.view.frame;
}];

Transition from view (one of the options) in slide out menu to another option in menu with button press and WITH navigation bar

For testing purposes, I'm using the demo that's provided on Github. Search SASlideMenu to find the github repo.
Screenshot 1:
Screenshot 2:
Ok, so I'm using SASlideMenu in my app and here is what I want to do:
In a nutshell, I want to go from the blue page (the one with the button that says "Press me to get to screenshot 1") with a button press, to another one of the options in the menu. I've added the option to get to screenshot 1 to the menu and clicking on this it takes me to that view WITH the navigation bar at the top.
The problem is, when I press the "Press me to get to Screenshot 1" button, it takes me to the screenshot 1 page without the navigation bar at the top of the view. I've used a modal segue to link the button to the view shown in screenshot 1.
I want this view to have the navigation bar just like in the blue screenshot.
Is this possible?
I hope this is clear. If you need any clarification, feel free to ask.
You can't reuse that top bar in different view's as it is here
But following may be solution
1. If top bar is navigation bar then use push segue instead of modal and setup buttons again
2. If you want to use same top bar, just mimic modal view presentation by writing custom segue
//code to mimic modal presetation will be similar to this
- (void)perform
{
//add as subview with origin y at bottom -50
CGRect frame = [[self destinationViewController] view].frame;
frame.origin.y = [[self sourceViewController] view].frame.size.height -50;
[[self destinationViewController] view].frame = frame;
[[[self sourceViewController] view] addSubview:[[self destinationViewController] view]];
//animate frame with new y postion
[UIView animateWithDuration:0.5 animations:^{
CGRect frame = [[self destinationViewController] view].frame;
frame.origin.y =[[self sourceViewController] view].frame.origin.y - SOME_OFFSET_VALUE_TO_SHOW_TOP_BAR;
[[self destinationViewController] view].frame = frame;
}];
}
3. If you dont wan't modal segue, then just use custom segue like in 2. and add your view (white one) as subview in area below navigation bar

Off by 20 pixels (y axis) when adding subview myNavigationController.view

I have a navigation controller with a menu button. When the menu button is pressed, the current view (complete with its navigation bar) should slide to the right, and a menu should simultaneously and contiguously slide in from the left. The details are explained in the comments in the code, below.
It works except in one regard. The current view (in this case, "Conversations"), when added back into the container view I implement, has to have its frame set to "y.min"=-20, or else there are 20 pixels above its navigation bar. However, when I set its y.min to -20, this shifts everything within its view up by 20 pixels. So when the menu button is pressed, everything in the current view suddenly jumps upwards by 20 pixels.
I can't figure out why this is happening or how to correct this. It is also possible that there's an easier way to go about all of this, but I'm not aware of one.* (*I'm not interested in third-party files. I want to learn to do this myself.)
Here is the code:
- (IBAction) showMenu:(id)sender
{
// get pointer to app delegate, which contains property for menu pointer
AppDelegate *appDelegate = getAppDelegate;
//create container view so that current view, along with its navigation bar, can be displayed alongside menu
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 548.0f)];
[container setBackgroundColor:[UIColor blueColor]];
//before presenting menu, create pointer for current view, to be used in completion routine
UIView *presenter = self.navigationController.view;
//present menu's VC. it is necessary to present its (table) VC, not just add its view, to retain the functionality of its cells
[self presentViewController:appDelegate.menuVC animated:NO completion: ^{
//obtain a pointer to the menu VC's view
UIView *menuTemp = appDelegate.menuVC.view;
//replace menu VC's view with the empty container view
appDelegate.menuVC.view = container;
//add the menu view to the container view and set its frame off screen
[container addSubview:menuTemp];
menuTemp.frame = CGRectMake(-260.0f, 0.0f, 260.0f, 548.0f);
//add the the view that was displayed when the user pressed the menu button. set its frame to fill the screen as normal
[appDelegate.menuVC.view addSubview:presenter];
presenter.frame = CGRectMake(0.0f, 0.0f, 320.0f, 548.0f);
//animate the 2 subviews that were just added; "PRESENTER"'S FRAME IS THE ISSUE
[UIView animateWithDuration:25.3f delay:0.0f options:nil animations:^{
[menuTemp setFrame:CGRectMake(0.0f, 0.0f, 260.0f, 548.0f)];
[presenter setFrame:CGRectMake(260.0f, -20.0/* or 0 */f, 320.0f, 548.0f)];
} completion:nil];
}];
}
Here is an illustration of my two options (click for higher resolution):
screen 1) The first screen shows the view before clicking the menu button.
The next two screens show two possibilities as the menu transition animation begins.
screen 2) This is what the transition looks like when I set presenter.frame.y.min to -20. As you can see, the button in the view has jumped up by 20 pixels.
screen 3) This is what the transition looks like when I set presenter.frame.y.min to 0. As you can see, a bar 20 pixels tall is present at the top. The blue color indicates the container view.
I had this problem some time ago when I didn't create my view controller tree correctly. My 20px off was caused by adding a UINavigationController view as a subview. I talked with the Apple Engineers in the labs at WWDC that year. They said I was using the navigation controller incorrectly, it needs to be a top level construct and you shouldn't put it in another UIViewController. That said you can put them in a container view controller like UITabBarController and UISplitViewController.
Your issue is not in the code you've posted it is in the architecture of your view controllers. I've uploaded a sample app to GitHub showing how to create a "Slide Menu" App like the FaceBook and StackOverflow iPhone Apps. See https://github.com/GayleDDS/TestNavBarOffBy20.git
The sample app uses a storyboard with Container Views in the root view controller to manage a UINavigationController (main view) and UITableViewController (menu view).
Now show Menu
See commit message cfb2efc for creation details. I started with the Single View Application template and you need to add the QuartzCore framework.

iPad app modalpopup view corner not get proper color...?

I'm developing iPad application, at some point I need to popup view on IBAction. And the same I done properly with below code.
SCSelection *vcSCSelection = [[SCSelection alloc]initWithNibName:#"SCSelection" bundle:Nil];
vcSCSelection.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:vcSCSelection animated:YES];
It's work properly and shows me my view which size is Form Sheet.
I need some Background custom color apply on this view, and which I maintain in popup view's - (void)viewDidLoad method as below.
self.view.backgroundColor = [UIColor colorWithRed:61/255.0 green:61/255.0 blue:61/255.0 alpha:1];
Now, my issue is when popup view shown It's covered with background color apply on it,except it's corner as below. As you can find that there is some corner space where color effect are not apply. I just highlight it with oval.
How can I overcome from this issue.
I had a similar problem and here's a quick write up with comments on how I did it. Note, this code is in the view controller which triggers the modal view presentation.
// Login Table View Controller
UITableViewController *loginPanel = (UITableViewController*) [mainStoryboard instantiateViewControllerWithIdentifier: #"LoginTVC"];
// Setup Login panel presentation style
loginPanel.modalPresentationStyle = UIModalPresentationFormSheet;
// Present Login Panel (called before view's bounds modifications so that it instantiates
[self presentViewController:loginPanel animated:YES completion:nil];
// ============================================
// Make form sheet's view slightly smaller or
// equal to the login panel's view so that corners
// don't have white color bleed.
// ============================================
// Set the bounds & clipping (very important) of the
// superview (which would be the formsheet's view
// when using UIModalPresentationFormSheet)
loginPanel.view.superview.bounds = CGRectMake(0, 0, 400, 380);
loginPanel.view.superview.layer.cornerRadius = 8.0f;
loginPanel.view.superview.clipsToBounds = YES;
// Set the bounds of the view being presented modally as UIModalPresentationFormSheet
loginPanel.view.bounds = CGRectMake(0, 0, 400, 380);

Resources