Strange autolayout issue since ios 11 - ios

I have a UITableViewController which I present modally (full screen) on iPad.
Since ios11 (and never before) I've got a lots of strange display problem where the UITableViewController is apparently, at some point, unable to properly compute its heights, and when I click on a cell actions for another index path is triggered. The controller contains cells which is defined in a xib and the problem disappears if I replace this cell by a vanilla UITableViewCell. On the other hand, fixing the height of the cell from heightForRowAtIndexPath does not resolve the issue.
Now the strange thing is, if this TableViewController is not presented within a new NavigationController but is simply pushed from the current view controller, everything works (almost) fine.
I am presenting my controller like that:
MyTableViewController *tvc = [[MyTableViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:tvc];
[self.navigationController presentViewController:navController animated:YES completion:nil];
Is there anything obviously wrong with the above or that could explain what I am getting ?

Related

UISplitViewController detailview changing result is gray area

I am trying to replace the detailview of a UISplitViewController for a quite a while now, but the solutions I found on the internet wasn't useful.
I am executing this:
DetailViewController* secondVc = [[DetailViewController alloc] init];
NSMutableArray* arr = [[NSMutableArray alloc] initWithArray:self.splitViewController.viewControllers];
[arr replaceObjectAtIndex:1 withObject:secondVc];
[self.splitViewController setViewControllers:arr];
DetailViewController is just a normal UIViewController (is this the problem?) I chose red as its background but I am seeing a completely gray area in the detail view after this code is executed.
What surprises me is that viewDidLoad and viewDidAppear functions are called for the DetailView class, but I can't see it on the screen. The self.view.frame is 0,0,768,1024 although all my settings are in landscape mode in storyboard.
I only want to use this in landscape mode, I don't need a generic solution.
What is the most basic way to change the detail view of a split view controller? I have looked at Apple's MultipleDetailViews but that felt like overkill since most of the code in it is about responding orientation changes, like hiding the master vc etc.
I suspect your problem is using alloc init to instantiate secondVC -- that would work if you made your controller's view in code, or in a xib with the name "DetailViewController". Since it appears that you're using a storyboard, then you should be using,
DetailViewController* secondVc = [self.storyboard instantiateViewControllerWithIdentifier:#"secondVC"]; // be sure to use this same identifier in the storyboard
In storyboard, select the view controller. On the right side, go to "Simulated Metrics" and pick "Detail" for "Size". As for the color, try setting it in viewDidLoad.

Adding UINavigationController inside splitViewController in iPad

I am using a splitViewController, My Detail View has a navigationController as a parent.
I have added it this way
My app is universal.So I have created different xibs for both iphone and ipad.
_moreOptions = [[MoreOptionsViewController alloc] initWithNibName:#"MoreOptionsViewController" bundle:nil];
_settingsView = [[SettingsViewController alloc] initWithNibName:#"SettingsViewController_iPad" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:_settingsView];
_moreOptions.settigsView = _settingsView;
self.splitViewController3 = [[UISplitViewController alloc]init];
// self.splitViewController3.title = #"More";
self.splitViewController3.delegate = _settingsView;
self.splitViewController3.viewControllers = #[_moreOptions, navController];
SettingsViewController has UITableView inside it. So the problem which i m facing is that , My Detail is not filling the full height on iPad, here is the screen shot
You can see the dark patch at bottom and this is my question of concern,
EDIT: I think I've found a fix, apply this to the UISplitViewController:
[splitVC setExtendedLayoutIncludesOpaqueBars:YES];
This property is iOS 7 only and seems to solve the problem. Look at the methods that replace -wantsFullscreenLayout: in UIViewController.h.
I'm having the same problem -- if I build on iOS 5 or 6, it works fine, the gap isn't there. Could it be an iOS 7 bug? If so, it's a particularly inconvenient one. Still searching for a workaround.
As far as I can tell from the current documentation, we're performing the correct steps:
(see "Adding a Navigation Controller to a Tab Bar Interface")
https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/CombiningViewControllers.html

UISplitViewController is not being displayed correctly

I created and loaded a UISplitViewController in an existing ViewController by writing the following code in the viewDidLoad method:
LeftPanelViewController *leftPanel = [[LeftPanelViewController alloc] initWithNibName:#"LeftPanelViewController" bundle:nil];
FirstViewController *firstView = [[FirstViewController alloc] initWithNibName:#"FirstViewController_iPad" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:firstView];
UISplitViewController *splitController = [[UISplitViewController alloc] init];
splitController.viewControllers = [NSArray arrayWithObjects:leftPanel, self.navigationController, nil];
[self.view addSubview:splitController.view];
[self addChildViewController:splitController];
[splitController didMoveToParentViewController:self];
Everything is fine except for the fact that the splitController is not being drawn in the borders of the iPad, there's a space between the top of the screen and the top of the view. Even when I rotate the iPad the left panel is also having the same problem.
SplitViewController doesn't have a xib file, and when I change the added view for another that has, everything is correctly displayed.
Any ideas of what may cause this problem?
Notes:
Compiling and running the project in the simulator multiple times causes the SplitViewController to be displayed sometimes without any problems and others with spaces between any of the edges of the screen and the view. Running in the iPad causes always the same problem.
First of all.. why do you implement a container view controller? I guess you just want to present the splitViewController on its own, right? Than don't add the view yourself.
Instead correctly set it as your rootViewController on your window (preferably in applicationDidFinishLaunching).
self.window.rootViewController = splitViewController;
Container View Controller are not needed in standard cases. So you should never need to use the following methods:
addChildViewController:
removeFromParentViewController
willMoveToParentViewController:
didMoveToParentViewController:
Check the documentation of UIViewController.
If you really wanted to implement a Container View Controller, than you need to take care of the layout yourself. So you need to position / size the view of the other controller yourself. Depending on if you use AutoLayout or autoresizing, you need to set correct constraints/flags.

UIPopoverController iOS 5.1 strange space when adding UINavigationController

I have some UIPopoverController that were working fine in 4.3/5.0 iOS iPad.
Now, with iOS 5.1 I have a strange space on top.
You can see both images, in 4.3/5.0 the tableView is just below the navigationController.
In 5.1, there's a space, like a blank row, but it's not a row, you can't select, you can scroll but the blank is there.
The problem appear when I use a UINavigationController
MassMediaViewController * massMediaViewController = [[MassMediaViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:massMediaViewController];
UIPopoverController * popoverMassMedia = [[UIPopoverController alloc] initWithContentViewController:navigationController];
[popoverMassMedia presentPopoverFromRect:textField.frame inView:self.scrollView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[... release objects ...]
Any ideas of what's the problem ?
thanks,
Related to this question
Oh man, I found the problem!
In the tableViewController's viewDidLoad I set the navigationBarStyle like this:
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
When you remove this line, everything works fine. Actually it doesn't do anything at all, because the barStyle is in that special popover style anyway. But because I'm using the same tableViewController for the iPhone, I set the barStyle.
I made another simple test project and was able to reproduce this bug and solve it by removing the barStyle setting.
I'll file a bugreport ...

pushViewController does not cause new controller to draw view

Preface: I am not using *.xib files.
I instantiate a UINavigationController in a class that effectively serves as my 'rootViewController'. This 'rootViewController' also has two UITableViewController members that are drawn on different sections of the iPad screen. One of which is set as the root view for the navigation controller. Let's call it tableViewControllerA.
The problem is, when I invoke pushViewController on a valid UINavigationController, I see no effect:
[tableViewControllerA.navigationController pushViewController:tableViewControllerX animated:YES];
I've gathered from the posts I've searched today, that this push method should in turn cause the screen to redraw the top of stack controller.view. This is not what I'm seeing.
It seemed there was a disconnect in my implementation, and it was time to reference a working example in my environment (xcode 4.0). Assuming the canned templates would provide a working basis, I created a new navigation-based applications. I simply modified didFinishLaunchingWithOptions: as follows.
UIViewController *view1 = [[UIViewController alloc] init];
UIViewController *view2 = [[UIViewController alloc] init];
view1.title = #"view1";
view2.title = #"view2";
[self.navigationController pushViewController:view1 animated:YES];
[self.navigationController pushViewController:view2 animated:YES];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:view1];
[view1 release];
[view2 release];
I found similar results. When I launch the simulator the screen title reads the title of whatever the self.window.rootViewController is pointing at. With the code as is, the title of the resulting top screen reads "view1". When I initWithRootViewController:view2, the resulting top screen reads "view2".
So please tell me I'm stupid cuz xyz...
Thanks.
Here are some references and suggestions:
Simple tutorial for navigation based application:
http://humblecoder.blogspot.com/2009/04/iphone-tutorial-navigation-controller.html
Here is another one to create the step by step navigation controller and adding the views:
http://www.icodeblog.com/2008/08/03/iphone-programming-tutorial-transitioning-between-views/
and here a bit advance with navigation + tab bar controller:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CombiningToolbarandNavigationControllers/CombiningToolbarandNavigationControllers.html
Without seeing your code, I have 2 theories:
Your syntax and calls are wrong when you do the push. Use this as a model:
-(void)Examplemethod {
AnotherClassViewController *viewController = [[[AnotherClassViewController alloc] initWithNibName:#"AnotherClassView" bundle:nil] autorelease];
[self.navigationController pushViewController:viewController animated:YES];
}
You are never adding the navigation controller to the view hierarchy which never adds the view either. Take a look at this.

Resources