WKWebview fail to open WKActionsSheet on presented UINavigationController - ios

I have a problem with my WKWebViewController.
I use this code to present:
SRWebWKViewController *webcontroller = [self.storyboard instantiateViewControllerWithIdentifier:#"SRWebViewControllerWKWebview"];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:webcontroller];
[self presentViewController:navController animated:YES completion:nil];
It is presented correctly, but when I press on any link I get this error:
Warning: Attempt to present <WKActionSheet: 0x7fc4f4c6f5e0> on <UINavigationController: 0x7fc4f4b9d9e0> whose view is not in the window hierarchy!
I searched a lot on the web but I can not find any solution that solves my problem
Thanks in advance

This is a bug in UIKit from iOS 8.0 until at least iOS 9.3.1.
We've seen this issue in PSPDFKit and after investigating the UIKit assembly and WKWebView sources we found a workaround that is still horrible, but not invasive.
The main strategy is to be selective and apply a workaround just in time - then clean up again. You can read the source code here:
https://gist.github.com/steipete/b00fc02aa9f1c66c11d0f996b1ba1265
And please dupe rdar://26295020 so this will get hopefully fixed in time for iOS 10. (The bug exists since iOS 8 and was first reported on iOS 8b5.)

Related

iOS App Maximise Disappears

I have developed an iOS app and everything is working as expected apart from the "maximise" icon in the detail view when it is turned sideways has disappeared.
I can't seem to find any documentation on this feature and suspect I have either not initialized something in the code or missed a setting on the story board.
Using objective C.
Knowing what it was called helps a lot :-)
Issue was the below code missing from viewDidLoad in the DetailViewController
UINavigationController *navigationController = [self.splitViewController.viewControllers lastObject];
navigationController.topViewController.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;

Xcode 7 navigationcontrller issue

I am facing some kind of issue in my when I compile my code with xcode 7.
Here is my code:
UIViewController *vcSomeObj = [self.storyboard instantiateViewControllerWithIdentifier:#"vcSOmeClass"];
vcSomeObj.channelID = detailOfUserTable.ID;
[self.navigationController setViewControllers:#[vcSomeObj] animated:NO];
This is working fine when I compile and run my code from xcode6.4.
This thing hang my application. And when I goes to any app and come agian to my app it will take to main controller and after sometime app crashes.
I can't find anything in debug.
In storyboard file We need to select English check box also otherwise application will hang an crash.
In my opinion.you set the current navigation's viewcontroller.what's happen to current viewController in navigation stack when you in current viewController,so ,I guess you can do like this
[self.navigationController setViewControllers:#[vcSomeObj,self] animated:NO];

Why does [uiActionSheet showInView:self.view.window] "hang" in iOS8?

I have an app in AppStore (iPhone-only, iOS3.1+ compatible, 2011 Xcode 3 compile) that has been working amazingly fine for three years untouched. Recently however it started "freezing" on iOS8 under certain conditions. That happens in couple of places, both when UIActionSheet is to be shown. Nothing pops on screen, the app does not crash but instead stays irresponsive to any taps; nothing in system console. The only way "out" after that happens is to kill the app manually from the task switcher and start it again.
I believe the reason is the way i show the UIActionSheet, which was as simple as these 3 lines, from a UIViewController method:
UIActionSheet* actSheet = [[UIActionSheet alloc] initWithTitle:#"Could not connect to [...]" delegate:nil cancelButtonTitle:#"OK" destructiveButtonTitle:nil otherButtonTitles:nil];
[actSheet showInView:self.view.window];
[actSheet autorelease];
I think the reason is the use of self.view.window, which is UIWindow (which inherits UIView, naturally) - and that just using self.view should solve the issue (i read here https://stackoverflow.com/a/26171717/226086 that showInView: now only works with UIView with UIViewController attached). Why did i use self.view.window in the first place - probably i read about this issue with cancel button alignment.
However, i am unable to reproduce the problem when compiling my app in Xcode 6 - and Xcode 3 cannot debug iOS8. And my conundrum is how do i exorcise a bug i cannot reproduce to verify.
Do you have insight on the changed behavior of UIActionSheet, what is causing the hanging in iOS8?
PS. Please don't tell me "UIActionSheet is deprecated in iOS8, use UIAlertController instead". That is an incorrect answer: "deprecated" does not mean UIActionSheet does not work in iOS8 no more - it is just discouraged for new code and may be dropped in next versions. But i want to keep compatibility with iOS5+ (my reasoning akin to this) so i rather fix the use of it - which i mention above seems fishy with showInView:self.view.window.
This is a long shot, but there is an issue in iOS8 related to rotation not working when the following line is left in your app delegate didFinishLaunchingWithOptions: method. The line is a hangover from pre iOS8 xcode generation and relates to the window for the application. Only affects iOS8. Previous versions all work fine.
The line is:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
This is nolonger needed and should be commented out. Given you are using self.view.window perhaps there is some side effect with UIActionSheet as well.
As I say, a long shot but seems a coincidence that your having an issue in iOS8 only related to using a window view.
I dont think you should have an issue using UIAlertController, as far as support for previouis versions of iOS are concerned you can try creating instance of UIAlertController using [[UIAlertController alloc] init] if it returns nil(which it will for older versions of iOS) you can use UIAlertSheet you are using currently.

presentViewController shows empty View

I have been trying to present a view controller on my app but whenever I present it, it gives me an empty view. I have searched a lot on the internet and the StackOverFlow but none of the solutions are working for me. Here is my code:
In my viewWillAppear, I am calling the method:
[self performSelector:#selector(presentConfirmationView) withObject:nil afterDelay:0.4];
and here is the definition to the presentConfirmationView:
ConfirmRegistrationViewController *confirmationRegistrationController = [[ConfirmRegistrationViewController alloc] initWithNibName:#"ConfirmRegistrationViewController" bundle:Nil];
[self presentViewController:confirmationRegistrationController animated:YES completion:NULL];
Any idea why this might be happening? BTW, I am using Xcode 5.0.2.
I have tried to shift the code to viewDidAppear as well but to no avail.
When this happened to me (Xcode 6.4, iOS 8.4 simulator), the fix was to delete the app in the simulator and also delete my Build folder (I guess a Product->Clean command might also have worked).

Aviary ios SDK memory not released after dismiss

I am using Aviary SDK 3.0 in my app, I put the Aviary code in a popover like this, but after I dismissed the popover using [popover dismissPopoverAnimated], the Aviary is still in the memory Heap, this is even true, even after I dismissed the parent viewcontroller. is it expected that the Aviary code is cleaned up after I dismiss?
in the action when use tap the photo. I present it here
AFPhotoEditorController *editorController = [[AFPhotoEditorController alloc] initWithImage:imageToEdit];
[editorController setDelegate:self];
if (popover == nil)
popover = [[UIPopoverController alloc] initWithContentViewController:editorController];
else
[popover setContentViewController:editorController animated:YES];
https://dl.dropboxusercontent.com/u/23238574/Screenshots/aviarypopover.png
From the docs:
"Note that pushing the controller onto a UINavigationController's stack is not recommended, since the Photo Editor itself uses a subclass of UINavigationController."
try presenting it modally, then what I do just to make me feel better about all memory getting cleaned is to make a strong property and go through the checklist
[editorController removeFromParentViewController];
editorController.delegate = nil;
editorController = nil;
something about clearing the delegate seems to clear my memory better, although, I don't think you need it.
also, don't forget:
"By default, Aviary keeps a small number of OpenGL objects loaded to optimize launches of Aviary products."
[AFOpenGLManager requestOpenGLDataPurge];
// to request a clear,
// "Calls to requestOpenGLDataPurge only apply to the currently loaded OpenGL data,"
You can set it to clear regularly with
[AFPhotoEditorCustomization purgeGPUMemoryWhenPossible:YES];
if you're doing this, it's a good idea to preload some of the editor if you know they'll be using it soon
[AFOpenGLManager beginOpenGLLoad];
This memory leak has been addressed in subsequent releases of the SDK. Please visit developers.aviary.com to get the latest version.

Resources