I am using JASidePanels to show a viewController on the right side of the screen.
The controllers are loaded from the Main storyboard in this manner from a JASidePanelController subclass:
-(void)awakeFromNib{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:[NSBundle mainBundle]];
TRMPracticeViewController *practiceVC = [mainStoryboard instantiateViewControllerWithIdentifier:#"Practice"];
TRMPracticeSetupViewController *practiceSetup = [mainStoryboard instantiateViewControllerWithIdentifier:#"PracticeSetupVC"];
[self setCenterPanel:practiceVC];
[self setRightPanel:practiceSetup];
[self setRightFixedWidth:practiceVC.view.frame.size.width/3.0f];
}
The TRMPracticeSetupViewController has a fixed frame in the storyboard of 200px x 320 px and I would like to maintain the width once the controller is loaded and added to the side (or at least a width proportional to the size of the screen).
However, once the vc has been loaded and added, its frame is set equal to the center view controller, which has of course the size of the screen. So, the views inside the right vc, go under the center vc because of the auto layout constraints that fix their margin to the container bounds.
How can I fix the right panel bounds width to e.g. 200px ?
JASidePanelController has a method for setting fixed width of either left or right panel. Just add this to your code:
self.rightFixedWidth = 200.0f;
Related
Collection view moves up in iOS 10.3.3. But work fine in iOS 11.0.
Can any one let me know how to fix this kind of issue which is realted with version
CollectionView Constrains.
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
MSProductCategoryViewController
*msProductCategoryViewController = [storyBoard instantiateViewControllerWithIdentifier:#"MSProductCategoryViewController"];
msProductCategoryViewController.title =titleName;
[self.navigationController pushViewController:msProductCategoryViewController animated:YES];
For CollectionView moving up issue please check if you have unselected the "Adjust Scroll View Insets" property of your ViewController in storyboard.
Attributes Inspector of ViewController
You have added top constraint with 20 value. I assume you wanted to add top padding for collection view. If that is the reason then I suggest using "Section Insets" property of CollectionView.
I am using constraints to lay out a view controller in my app. Here is a screenshot of the completed layout:
From what I've read, the constraints being blue means they are good (there is enough information to determine layout).
In another view controller, I am presenting this view controller with a popover presentation style like this:
- (void)annotationTapped:sender {
...
AJFAnswerViewController *answerViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"AnswerViewController"];
answerViewController.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:answerViewController animated:YES completion:nil];
answerViewController.answerLabel.text = tappedAnnotation.name;
answerViewController.quesitonLabel.text = tappedAnnotation.questionText;
answerViewController.saveBlock = saveBlock;
UIPopoverPresentationController *popover = [answerViewController popoverPresentationController];
popover.sourceView = tap.view;
popover.sourceRect = tap.view.bounds;
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
Here is what I see when I run the app:
It seems that the constraints are not being applied. I have verified that my storyboard ID is correct, and that the popover is using the view controller in the popover (for example, if I change the explicit height to something like 100, it is respected).
Am I missing a specific method call, or going about the storyboard layout wrong?
Resolved by applying the constraints to the wAny hAny size (as suggested by Dean, thanks!).
select all the labels and make them embed in a new view (Xcode-editor-embed-view)
select the view which the labels embeded in and add a new alignment constraint (horizontal center in container : 0; vertical center in container : 0)
rebuild those label constraint
I just added a separate view controller and xib in a project that uses storyboards throughout. I display it from inside another view controller with the usual code:
OtherVC *othervc = [[OtherVC alloc] initWithNibName:nil bundle:nil];
[self.view addSubView: othervc.view];
In portrait orientation, he xib displays and auto rotates properly right out of the box.
But when I display it when the iPad is already in landscape, the size of the view is portrait and positioned off to the left.
What's going on? There doesn't seem to be a way to add constraints to the view.
Thanks!
This is not the right way to present a separate viewController.
The problem is that you are adding a view on the actual view..but this view have a certain frame that will remain the same when you add it on the view..in both case (landscape and protrait). So, to understand, you should check the orientation and then set the frame of the view properly. But as i said, the way that you are using is wrong.
In your case you should use segue from storyboard.
Or, at max, by code but with something like:
OtherVC *othervc = [self.storyboard instantiateViewControllerWithIdentifier:#"Identifier"];
[self presentViewController:othervc animated:YES completion:nil];
where Identifier is set in your viewController in the storyboard by the inspector panel at the right.
Or, if you instead wanted to say "NIB" you should to do:
OtherVC *othervc = [[OtherVC alloc] initWithNibName:#"yourNibName" bundle:[NSBundle mainBundle]]; //Or your correct bundle but i guess will be this.
[self presentViewController:othervc animated:YES completion:nil];
So after this, if you are sure to have set both orientation on your project, your view will be in landscape.
Now you will use AutoLayout or normal mask rules without AutoLayout to manage the elements on the view.
I have a UIViewController (red) set as the first tab of a UITabBarController as shown in the storyboard below. This view controller is a container view controller and loads a UINavigationController inside its contentView (the white rectangle inside the red view controller).
This is my code for loading the navigation controller inside the red view controller's contentView:
- (void)viewDidLoad
{
[super viewDidLoad];
// instantiate navigation controller
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UINavigationController *navigationVC = [storyboard instantiateViewControllerWithIdentifier:#"N"];
// place navigation controller inside content view
[self addChildViewController:navigationVC];
navigationVC.view.frame = self.containerView.bounds;
[self.containerView addSubview:navigationVC.view];
[navigationVC didMoveToParentViewController:self];
}
From what I know about view controller containment this should work as I am explicitly setting the frame for the navigation controller. However, when there are enough cells in the tableView to exceed the container's height there is always a bar at the end of the tableView when I scroll down. I have set the tableView's backgroundColor to orange and the cell's backgroundColor to white in order to see the difference.
How do I get rid of that orange gap at the end of the tableView?
(Note: I am not using autolayout and I need a solution that works for both - iOS7 and iOS6.)
I know you are also looking for an answer which works on iOS 6, but on iOS 7 and above you can use
self.extendedLayoutIncludesOpaqueBars = YES;
Have you tried setting self.edgesForExtendedLayout = UIRectEdgeAll; in -(void)viewDidLoad of Table View Controller - Root?
Note: iOS 7 only
I have a UITableViewController that I am trying to display in a UIPopoverController. No matter what do, the tableview is always displayed at full size within the popover.
In my StoryBoard I've set the UITableViewController's Size to Freeform. I've explicitly set the UITableView's height and width in the Size inspector.
Here is how I setup the controller and popover:
UIStoryboard* sb = [UIStoryboard storyboardWithName:#"MainStoryboard-iPad" bundle:nil];
self.settingsController = [sb instantiateViewControllerWithIdentifier:#"SettingsViewControllerID"];
self.settingsPopover = [[UIPopoverController alloc] initWithContentViewController:_settingsController];
I've also tried setting the controller's popover size explicitly:
self.settingsController.contentSizeForViewInPopover = CGSizeMake(400.0, 400.0);
When I run the app and activate the popover - it is almost as tall as the main screen.
Am I missing something obvious here?
Thanks in advance,
CS
You can change the tableView size by using below code.
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UIStoryboardPopoverSegue *popoverSegue;
popoverSegue = (UIStoryboardPopoverSegue *)segue;
UIPopoverController *popOverController = popoverSegue.popoverController;
[_popOverController setPopoverContentSize:CGSizeMake(width, height)];
}
The UITableViewController always wants to be the full size of the window, or popover (which is a special kind of window). If you want a smaller table view, use a UIViewController instead as the content controller of your popover. You should then be able to resize it in IB.