In iOS14 devices, my app does not load the view controllers and just freeze the app.
self.navigationController!.pushViewController(itemDetailVC, animated: true)
On all device below iOS 14, it works perfectly fine. But here it does not load the next view controller.
While debugging I figured that viewDidAppear never gets called.
Anyone else facing such issue.
Thanks in advance.
Getting very strange problems with UINavigationController transition animations. Resulting view controllers appear broken and shifted. Unbelievable how broken it is.
The issue is due to mistakes on view controller override functions. Double check your onViewWill/onViewDidAppear. The should override the correct function
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Logger.verbose(topic: .appState, message: "viewWillAppear")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Logger.verbose(topic: .appState, message: "viewDidAppear")
}
Also, if you are using a UITabBarController, make sure the same thing is done correctly there too.
Related
I'm trying to override the NavigationView behavior:
public partial class CustomizableNavigationView : NavigationView
{
public CustomizableNavigationView()
{
// This gets called
}
protected override void OnApplyTemplate()
{
// This doesn't
}
}
It works on UWP, but not on Android. On Android, it doesn't call OnApplyTemplate and the screen remains blank, there's not content. Questions:
Why doesn't OnApplyTemplate get called on Android? I see that here: https://platform.uno/docs/articles/implemented/windows-ui-xaml-frameworkelement.html it says OnApplyTemplate() is on all platforms
There's no error or anything displayed in the Output panne in VS while running with debugger. Should there be any in this case? Do I need to enable something to log errors?
I noticed that if I don't use partial it gaves me error saying partial is required. This is required only on Android, why is that? A more in-depth explanation would help a lot to understand how things work.
Once I figure out why OnApplyTemplate is not called, I want to do this:
base.OnApplyTemplate();
var settingsItem = (NavigationViewItem)GetTemplateChild("SettingsNavPaneItem");
settingsItem.Content = "Custom text";
My hunch is this won't work on Android. Am I correct? :)
Jerome's answer explains why OnApplyTemplate() was not getting called, to address your other questions:
You can configure logging filters for Uno, this is normally defined in App.xaml.cs. Warnings should be logged by default.
The partial is required because Uno does some code-gen behind the scenes to create plumbing methods used by the Xamarin runtime. Specifically because the control is ultimately inheriting from ViewGroup on Android, it's a native object, and requires special constructors that are used only by Xamarin's interop layer. There's some documentation in progress on this.
Try it and see. :) GetTemplateChild() is supported, and setting ContentControl.Content in this way is supported, so I would expect it to work.
At current version (1.45 and below), the application of styles is behaving differently from UWP. We're keeping track of this in this issue.
The gist of the issue is that Uno resolves the style using the current type and not DefaultStyleKey, and cannot find an implicit style for CustomizableNavigationView.
A workaround for this is to either create a named style from the default NavigationView style, or create an implicit style that uses CustomizableNavigationView as the TargetType instead of NavigationView.
I'm trying to solve a view placement bug that has arisen as of iOS 9. I am instantiating a view controller from a xib file (non-autolayout) and then pushing this onto my UINavigationController.
The problem is that when the view controller's viewWillAppear method is called, its frame has not yet been adjusted to the navigation controller's size and is still what was set in the xib file. It doesn't get set properly now until viewDidAppear.
This is completely screwing up my code. Does anyone know precisely what has changed that is causing this and what is the best way to handle it? I don't want to wait until viewDidAppear because this will look bad and make for a poor user experience.
I am also looking for the best fix.
My temporary one is to call the code that was in "viewDidAppear" in "viewDidLayoutSubviews". That way, my code will get called as soon as the frames are set.
But, make sure to add a boolean or something so that your code doesn't get called every time viewDidLayoutSubviews is called
-(void)viewDidLayoutSubviews{
if (didLayoutSubviews == NO){
didLayoutSubviews = YES;
// perform code that was in viewWillAppear
}
}
I occurred this issue too,
try to uncheck option "Resize View From NIB" from storyboard
Try moving the layout code from viewWillAppear to viewWillLayoutSubviews.
A little bit updated NickProvost's answer:
private var loadViewToken: dispatch_once_t = 0
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
dispatch_once(&loadViewToken) { [weak self] in
if let wSelf = self {
wSelf.setupView()
}
}
}
I am working with objective-c/swift and interface builder trying to make my application navigation accessible. I cannot figure out how to get my header to work when you use the accessibility rotor and select "headings." My heading title is set in Interface Builder (IB). Within IB its set in a Navigation Bar > UINavigationItem > Title attribute. I think what I want to do is find a way to add the UIAccessibilityTraitHeader to the UINavigationItem, but you cant do that in IB. I also tried making an outlet then adding the trait manually in viewDidLoad method. This is not working. If anybody could help that would be great!
#IBOutlet weak var menuTitle: UINavigationItem!
override dynamic func viewDidLoad() {
self.menuTitle.accessibilityTraits |= UIAccessibilityTraitHeader;
}
I found out this is a defect with the iOS Simulator (X-Code 6.2). It does not show "Headers" as a trait. It worked fine when I loaded it onto a device and tested it.
I have a simple App with two views. As soon as the first view is loaded I'm performing a Touch ID sensor authentication (see also this question):
func testTouchID()
{
if touchIDContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error:&touchIDError)
{
touchIDContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: reasonString, reply: {
(success: Bool, error: NSError?) -> Void in
if success
{
self.performSegueWithIdentifier("showSecondView", sender: self)
return;
} else {
With this code the segue is performed, but the second view just appears for a moment and then the App goes back to the first view.
It seems that the code inside canEvalutePolicy is not finished, so the navigation controller push the first view.
I tried several things like:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
NSOperationQueue.mainQueue().addOperationWithBlock
And also a combinations of these method, but I'm not able to perform the segue to the second view and stay in the second view.
Can anyone help?
Thanks and best,
Guido
I was able to solve this issue. The problem was the navigation controller.
My solution: the first view is not anymore embedded in a navigation controller, it just have a segue to a second view.
Then the second view is embedded in a navigation controller (along with others views) in order to have the navigation behaviour between views that I want.
Important is to use dispatch_async in order to "load" the navigation controller as soon as the user authenticates:
if success {
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("xxx", sender: self)
Without dispatch_async the second view appears but the navigation logic of the navigation controller is missing for around 15 seconds.
I have a timer in my application. For every 30 min, it will hit the web services and fetch the data and updates the UI. The application was working fine till yesterday. Suddenly, because of some issue, the web services were not available for some time. During that period, Application displayed the RPC Error multiple times(More than 100 alert boxes) in alert window. Because of this alert boxes, my application was hanged and i was not able to do anything.
I have tried several approaches, but nothing worked.Finally, I have tried to use a flag. In all the approaches, this looked promising. so i have implemented it.Basically, in this approach whenever we open an alert we will set a flag.While opening and closing alert we will reset this flag. But it didn't work as expected. Is there any approach, which can help us in avoiding multiple alert windows.
Please help me, to fix this issue.
I would write wrapper for opening alerts, and use only this wrapper, not Alert.show in the code:
public class AlertWrapper {
private static var lastAlert:Alert;
public static function showAlert(text:String, title:String):void {
if (lastAlert) {
PopUpManager.removePopUp(lastAlert);
//or
//return; //ignore last alert
}
lastAlert = Alert.show(text, title, null, 4, onAlertClose);
}
private static function onAlertClose(event:CloseEvent):void {
lastAlert = null;
}
}
Imports are missing, but I hope the idea is clear.