WebView in MasterView Controller - ipad

I would like to display a webview useful to unlock a website providing data for the detail view controller in the master controller of the iPad version. Yet when I do so, similarly to what I successfully do with a TableView, just the ViewDidLoad callback gets called, but not the ViewWillAppear and in general it seems nothing happens like the view were not shown. My code seamlessly works in the iPhone version, while I checked the StoryBoard several times without finding anything suspect. Any idea about what is the reason for that and a solution?

At any rate I substituted the MasterController with a PopUp and everything works finely: still doubtful why a WebView cannot be shown in the masterViewController: perhaps just tableviews may show there.

Related

Presenting a specific view controller messes up the app on device (works on simulator)

I'm facing a very weird bug. I have a button and I'm pushing a view controller normally, using segues. However, when I push the view controller the whole app layout messes up: it sometimes works, sometimes glitches such as leaving me with a blank view with nothing but the tabbar, or previous view controller still being seen but transformed to somewhere else in the screen etc. If I manage to go back, it always works fine after the first try. Here are some observations:
Problem is specific to device (iPhone X). Simulator (even the same model and same OS version) works perfectly.
Switching to modal doesn't matter. The "glitchy look" animates a bit different, but the problem is still there.
Turning off animation in transition doesn't matter. It presents me a glitchy screen instantly, just without animation.
Pushing/presenting the view controller from code (as opposed to storyboard segue) doesn't matter. Exactly same.
Giving a delay (e.g. half second) after tapping the button before presenting the view controller doesn't change anything. Just wanted to try this to see if some race condition is present on tap, for whatever reason.
The problem is specific to one view controller. Presenting anything else at the same segue/state doesn't cause any problem.
The problematic view controller doesn't have anything special at all: It's actually just a wrapper with three child view controllers, something I commonly do:
When I'm trying to present the problematic controller, I'm always getting this weird log: [Render] CoreAnimation: failed to allocate 1223558576 bytes
My application is definitely not out of memory. It's using ~50MB on iPhone X at the time of problem. It's a media app and can allocate ~500MB with no issues or crashes when shooting/filtering video etc.
The problem occurs if a specific embedded view controller (the second one of three) is present. For example, if I remove the embed segue to that, it seems to run perfectly.
That embedded view controller is a simple UIViewController subclass that just has a table view and some cells.
What might be going on?

Is there anyway I can find out the viewcontroller being shown on the screen in the app without using viewWillAppear/viewWillDisappear

I am trying to find the page the user is viewing at a given point of time. Is this possible without making any call from viewWillAppear or viewDidLoad. I have tried keywindow but it works only for navigation controller and it doesnt work as expected for tabBarController or a containerView.
Thank you.

Making a view Controller stay active (in Background)

I've got a view Controller which manages my TV Playout (HDMI Apple AV Adapter). Everything works fine. I call my view Controller using a popover on the iPad.
When I open the popover, the external screen is recognized and I can work with it. But when I close the popover View (which means I send my TV Playout View Controller to the background) the TV screen (logically) turns black.
Is there a possibility to tell my view Controller to hold the picture on the TV screen by quit?
Like "pseudocode"
[TVOutViewController stayActiveInBackground]; //pseudocode
Thanks in advance!
I suspect you've coded your view controller so it explicitly shuts down the external UIScreen/UIWindow pair when it becomes inactive. I suggest you move the external screen code out of your popup's view controller and into an object which has a lifetime independent of what's going on on the internal screen, e.g. your application delegate or an object referenced by it. Then just send that object messages from your popup view controller in response to user events.
There's nothing about the Apple APIs that causes this kind of behaviour - it's purely a consequence of how you've designed your app. As such I don't recommend trying to force the view controller to stick around. Instead, try to find a better structure for the app. A view controller should only be responsible for its view, not application state.
OK guys, By chance, I found a solution (or at least a workaround). Be sure to manage the problem using a UISplitViewController with your TVOutViewController as the masterViewController and the ContentViewController as the detailViewController. Apple already did the work. Thanks anyway! :)

How to update behind presentModalViewController when using UIModalTransitionStylePartialCurl?

How do I make a curled-up view update live as the user interacts with view being presented with presentModalViewController: under it?
The behaviour I want:
User taps a view settings button.
User taps controls in the view settings screen. Rather than dismissing view settings, the view automatically updates in the background.
User taps something to dismiss view settings.
Imagine if in Maps tapping Map, Satellite, Hybrid didn't uncurl automatically but just updated the display.
I'm able to get notification that something's changed from the settings controller back to the main view controller. The main view controller can update and signal that it should redraw parts of itself, but actually updating the screen is intermittent. It will work 5 times in a row, then not work a couple times, then work another 5 times in a row. Dismissing the modal view always catches up the view underneath, however, so I assume the rendered image of my view is sometimes being cached or not being redrawn despite my request. But I can't think of a way to verify this.
This happens on both the device and the simulator.
While there might be multiple root causes of this behavior, here's a common issue I've seen that causes 'delayed' or 'intermittent' updates to UIKit views.
If the statements that update your presenting view (or the presented view) are running in a dispatch queue other than the main queue, UIKit may produce inconsistent results and timing in the actual UI update. You can usually tell by putting a breakpoint on the statements that update the UI and examining the name of the 'queue' displayed in Xcode's left-side debugger view. It should be 'com.apple.main-thread'. If it's not, that could be your issue. This can happen in quite a few delegate methods such as the network APIs.
Try wrapping your UI updates in:
dispatch_async(dispatch_get_main_queue(), ^() { ... }); and see if that helps! You should only do this when needed and take care to use block-safe techniques as always.
I tested this in a brand new Universal app for iOS 7.0.3 using the iPad simulator with a view controller presented using the partial curl transition. I was able to replicate the original issue, including the intermittent update and the 'snap' update when dismissing the presented view by using a background queue in the code I provided above. Once I switched to the main queue, everything worked A-OK.
Let me know if this helps or if there was some other issue :)

iPad UISplitView initial state in portrait: how to display popover controller widget?

I'm working on an iPad app that uses a UISplitView. Inspired by http://blog.blackwhale.at/2010/04/your-first-ipad-split-view-application/, I display a button in my detail view when in portrait mode that shows the popover controller. This works great. However, the appropriate UISplitViewControllerDelegate message is only sent when the device rotates. So, when the app first loads (in portrait mode), my navigation button is not visible.
Is it possible to somehow convince the UISplitViewController to send that message on load or something, or do I need to re-implement my own popover logic to get things working?
Thanks,
-Patrick
We had the exact same issue and it turned out that this thread had the right clues. When comparing our app with the SplitView template, we noticed that the split template does exactly what was mentioned here: set the UISplitViewController as the root view controller in application:didFInishLaunchingWithOptions.
Out previous solution linked the split view controller in the XIB directly to the window. While this works it seems the split view has difficulties getting the startup orientation and the missing button occurs. When we removed the link in the XIB and created it in code in the app delegate, everything ran fine.
That's weird. Maybe you missed something. Take a look at the template based on a splitController. It works fine form very startup no matter in what mode the app was loaded.
did you make sure that your UISplitViewController's view is the only subview of your UIWindow, and that you added it inside the application:didFinishLaunchingWithOptions: method of your app delegate

Resources