UITableView inside a Navigation Controller does not scroll after dismissing presentViewController - uinavigationcontroller

I am showing a Modal Presentation View in a Navigation Controller by calling
[self.navigationController presentViewController:controllerA animated:YES completion:nil];
And I am dismissing the controllerA by calling
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]
After the dismiss is done the UITableView in in the previous navigationController does not scroll up and down where as it did before the presentViewController was called. Do I need to do something after dismiss to make the UITableView scroll again.

The problem was that I had a Header View in the UITableView and I needed to uncheck the "Use Autolayout" (in the File Inspector section) from the Xib file as I was loading the Header from a Xib.
Unexpected scroll behavior after adding rows to UITableView

Related

UINavigationController and large titles when popping ViewController

I have a UINavigationController which has its navigationBar configured to prefersLargeTitles = true and isTranslucent = false.
The first view controller in the navigation stack is a UITableViewVontroller with its navigationItem configured as largeTitleDisplayMode = .always. If I push a further view controller with largeTitleDisplayMode = .never and pop it again, the first view controller is in a state where the large title is collapsed. I have to scroll up to enlarge the title again.
Is this intentional behaviour of iOS 14? Is there a way to restore the large title?
Edit: I just realized, that the behaviour is tied to the isTranslucent property of the navigation bar.

Storyboard UINavigation Controller Back Button Text

In XCode 4.5.1 creating a storyboard app with a Navigation controller, I am having a hard time trying to set the BACK button for any view controllers that are pushed. I'm using segue's and the view controller shows as expected. However I want to change the name of the navigation bar and back button dynamically and placed this in my ViewWillAppear:
self.title = #"Select Songs";
[self.backButton setTitle:#"Add"];
changes the title of the navigation bar but the back button still displays the NAME of the pushed window rather than the text "Add".
The Simulated Metrics are all Inferred. I also added a BarButtonItem to the black tray below the view in Xcode and wired up the backButton of the viewcontroller to the backButton, yet the text still does not appear.
Adding the following log messages also yield something interesting: (and yet the titlebar is updating correctly)
-(void) viewDidAppear:(BOOL)animated {
NSLog(#"%s %#", __FUNCTION__, self.navigationItem.backBarButtonItem);
NSLog(#"%s %#", __FUNCTION__, self.navigationController.navigationItem.backBarButtonItem);
}
2012-10-14 15:18:41.835 xxxx[2690:907] -[ViewController viewDidAppear:] (null)
2012-10-14 15:18:41.838 xxxx[2690:907] -[ViewController viewDidAppear:] (null)
The accepted answer is a hack, this is the way to do it...
Open StoryBoard
In Document Outline window find ViewController to which you want to
return to
Click on Navigation Item of that ViewController
In Attributes explorer change Back Button value to your custom tile
That is it, enjoy...
The back button will show the title of the previous view and if no title is set it'll show 'Back'.
So in your prepareForSegue method, you can change the title of the current view before the next view is pushed. The back button will then show whatever you set the title to.

dismiss ModalView Controller with UINavigation

hey guys in my app there's a parentViewController and a modalViewController. i managed to display and dismiss the modal view using storyboard and class methods. but what i need is after dismissing the modal view, parent view should push to another viewController. is there any way to do this??
Assuming that self is a parentViewController (after dismissing the modal view):
[self.navigationController pushViewController:viewController animated:YES];

Substitution of detail view controller does not cause viewWillAppear to be called

I'm porting my iPhone app to iPad. On iPhone I select row in the table, and after that the next view controller is pushed to the top of navigationController (now navigation is performed on the left part of split view controller). For iPad i modified the code this way:
if (deviceIsIPad())
{
UISplitViewController *svc = (UISplitViewController *)[self findNearestParentOfClass:[UISplitViewController class]];
svc.viewControllers = [NSArray arrayWithObjects:[svc.viewControllers objectAtIndex:0],
nextViewController,
nil];
}
else
[self.navigationController pushViewController:nextViewController animated:YES];
There are no problem at iPhone code (when controller is pushed to navigation controller), but on iPad viewWillAppear: is not called (viewDidLoad is called however), while I have a reason to perform some customization right in viewWillAppear:. Why is it not called, and what should I do to force it to be called?
Much thanks in advance!
Not exactly sure what you're trying to do here but simply initializing a splitview controller and adding controllers to it does not force views to appear. You have to add the splitview controller's views to the window.
Here is the code from the Xcode Splitview template's app delegate's applicationDidFinishLaunching:
splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:navigationController, detailViewController, nil];
splitViewController.delegate = detailViewController;
NSLog(#"master=%#",splitViewController.viewControllers);
// Add the split view controller's view to the window and display.
[window addSubview:splitViewController.view];
[window makeKeyAndVisible];
The views in the navigation controller appear because it is already attached to the window and displaying the view of one of its controlled controllers.
Edit:
From Comments:
All initialization code you are quoted
here is already performed. Now, let's
assume one have a table on the left
controller, then he select another row
there, and want to replace right
controller with another one.
splitViewController.view is added on
the window фдкуфвн, because some GUI
elements initialized in viewDidLoad,
are properly presented on view
It sounds like your problem arises because the detail (right-side) view of a splitview controller is always visible i.e. it only appears i.e calls viewWillAppear, once immediately after first being loaded. There is no point at which the detail side has no view present. I'm not sure what entirely swapping out viewControllers of the splitview will do.
If you want to change the detail view on the fly. You need to put a navigation controller in the right side and then push and pop view-controllers in that nav in response to events in the right side controller.
Look at how the iPad iPod app works. You have a leftside view of playlist and on the right side, a list of all the songs in the playlist. Selecting a song pushes a song detail view on top the list of songs.

UIBarButtonItems not showing up on UIToolbar

I have a UINavigationController with toolbarHidden set to NO.
I have added UIBarButtonItems to navigationController.toolbar.
The toolbar is displayed, but the buttons are not...
What gives?
Ok so apparently I misunderstood the usage of the setItems method on navigationController.
To remedy this I set the toolbar items on each view controller that is pushed onto the navigation controller's stack.
I guess if I wanted to have one toolbar persist through all the views I could add a new toolbar to the view controller holding my navigation controller then simply invoke setItems on my navigation controller.
I digress.

Resources