Showing a masked BTProgressHUD without blocking the tab bar? - ios

Is it possible to show a BTProgressHUD with a mask without preventing interaction with the tab bar? In other words, can the mask on a BTProgressHUD be constrained to just the tab's currently shown view controller instead of the full window?
BTProgressHUD.Show(status: "Oh hai", maskType: ProgressHUD.MaskType.Gradient);
I am trying to swap out MTMBProgressHUD for BTProgressHUD (because reasons). Unfortunately, when I show a BTProgressHUD with a mask, it will block the user from selecting another tab while it is shown (something MTMBProgressHUD didn't prevent). I definitely need to block any progression/interaction within the current tab's view controller, but I don't mind if the user switches to another tab instead of waiting for the current tab to complete whatever task is requiring the progress HUD.
Here is the full sample code Gist. It is a bit more complex since it includes the tab bar controller and each tab needs to be able to control their own individual HUDs (when this issue is resolved).

After some discussion on Twitter with the creator of BTProgressHUD, it was determined this isn't possible in the current v1.15 release. He suggesting modifying the source to make this happen. I was able to put together the a working version in just a few lines. (It would still need work to integrate with the BTProgressHUD.Show methods that use a shared instance, but I need discrete HUDs per tabs.)
If you build from this fork, you can then create a BTProgressHUD with a parent view (vs. defaulting to the window) which will restrict the coverage of the overlay mask.
var progressHud = new ProgressHUD(View); // ctor overload requires the forked version
progressHud.Show(status: labelText, maskType: ProgressHUD.MaskType.Gradient);

Related

Is it possible that an iOS application can have more than one window?

I have been asked this question many times in the interview searched every where didn't get any proper answer.So finally posting this question here.
You may go through this.
Yes, you can have multiple windows. A key window is the one who receives the user input.
Starting with Rob's answer I played around a bit and would like to write down some notes for others trying to get information on this topic:
It is not a problem at all to add another UIWindow. Just create one
and makeKeyAndVisible. Done.
Remove it by making another window
visible, then release the one you don't need anymore.
The window that is "key" receives all the keyboard input.
UIWindow covers everything, even modals, popovers, etc. Brilliant!
UIWindow is always in portrait implicitly. It does not rotate.
You'll have to add a controller to the new window's root controller and let that handle rotation.
(Just like the main window) The window's level determines
how "high" it gets displayed. Set it to UIWindowLevelStatusBar to have it cover everything.
Set its hidden property to NO. A 2nd
UIWindow can be used to bring views on the screen that float on top of everything. Without creating a dummy controller just to embed that in a UIPopoverController.
It can be especially useful for iPhone where there is no popover controller but where you might want to mimic something like it.
And yes, it solved, of course, my problem: if
the app resigns activation, add a cover window over whatever is
currently shown to prevent iOS from taking a screenshot of your
app's current content.
Generally one application require only 1 UIWindow, but still there may be some scenarios where you need to use multiple UIWindow in one application.
For example, you wish to show a view on the top of system AlertViews, or can the default Keyboard.
UIWindows are the special UIViews, for which their display order is controlled by .windowLevel property.
You don't need to add a new UIWindow as a subview of any of view. You can simply create a new UIWindow and call either window setHidden:NO or window makeKeyAndVisible depend on the level, you have given to it.
There are three default window enum levels defined:
UIWindowLevelNormal
UIWindowLevelStatusBar
UIWindowLevelAlert
Of course it can have multiple windows. Just, only one to be displayed at a time, that's the keyWindow. You can have multiple windows stored in array or whatsoever, and make them keyWindow when you want to display them.
And, yeah, read the documentation #Mannopson suggested, it's very useful.

How do you add the stock apple watch loading screen?

In many apple watch apps during Apple's "Spring Forward" when the apps pushed to another interface controller, they looked like this:
Then the interface controller would load
I am perfectly aware that this screen appears when the app starts up, but I want to show the stock loading screen after I push an interface controller
**I do not want to use image sequencing to achieve this
Also apple has sample code you can download called "Lister" that shows the loading symbol after every interface controller push, without image sequencing
How can you achieve this??
TL;DR
Either use the system behavior in the "Hides When Loading" checkbox under the Attributes of the Interface Controller and let the system manage it like in the example code or...
Create your own interface controller that will have to use a image sequence.
Longer Explanation
Your confusing what's actually possible. The stock loading screen isn't something that you can actually call nor manipulate. It's the default loading animation for a controller that hasn't finished awakeWithContext:. That's why you see it in the example code.
You can actually control it in the storyboard. Select or deselect the "Hides When Loading" checkbox under the Interface Controller section of the Attributes of the Interface Controller.
However, if you want control over when/where, you will have to create your own and yes that does mean you have to use an image sequence. There really isn't another way to do that animation currently without an image sequence.

Get the default back indicator image of a Navigation bar

I want to use the default image of the back button of a navigation controller in
IOS7 elsewhere in my application.
How can i obtain that image?
Programmatically in runtime, you can't.
What you can is
Use extracted elements, e.g. from these sites:
http://avexdesigns.com/ios7-psd-templates/
http://www.teehanlax.com/tools/
Extract it yourself, using Resource extractor
Snapshot the screen and cut it out yourself (most inconvenient option).

What is the purpose of UIWindow?

I've always seen references to an app's 'window', and I see that AppDelegates usually have a UIWindow property called 'window'. So I'm just wondering how to perceive this UIWindow object. I see that it's a subclass of UIView, so I guess technically it's a View right? So would it be safe to say it's like the Superview of an entire app? Also, when and why might I ever refer to it? What value does it add?
I know there are a lot of questions in there but just some overall context on UIWindow would be nice.
You might want to check out the About Windows and Views section in the View Programming Guide for iOS.
In iOS, you use windows and views to present your application’s content on the screen. Windows do not have any visible content themselves but provide a basic container for your application’s views. Views define a portion of a window that you want to fill with some content. For example, you might have views that display images, text, shapes, or some combination thereof. You can also use views to organize and manage other views.
Also note that an iOS application usually only has one window. An exception would be, if an app displays content on an external screen.
UIWindow
The presentation of one or more views on a screen is coordinated by UIWindow object. In iOS application usually only has one window. while View multiple. Windows and Views both are used for present your application’s content on the screen. Windows provide a basic container for your application’s views but not have any visible content. The view is a portion of a window where you can fill with some content.For example, you might have views that display images, text.
ProblemStucks
Window is like a topmost UI container for any iOS application. It sits above all of your views and viewControllers.
Ask me why it is needed, And I say it makes the UI structure more clear in terms of view hierarchy and event handling. For example any user event, when not handled by the innermost view, goes up the view hierarchy eventually to the window object if no other view in the hierarchy handles it.
Another example is the rootViewController of a window which handles view-specific details of the application.
There will be mostly one window for an application. But I have worked on an app which used a shared framework for user authentication. And there, we had a separate window specific to that auth framework. Why separate window you ask, and here I go again, there are 2 important use cases,
As I mentioned it was a shared auth framework. Hence different apps could use the same framework for user authentication which uses its own window for login screen etc.
There was a session timeout after which, a login screen had to pop up regardless of what user is currently doing on the screen. This can get really tricky if we don't use a separate window.
I hope you can understand essence of a window after reading these examples.

iOS system icons and custom buttons

i'm working on my first app and the problem a have is that the application interface design is quite customised, (even though it is a tab bar based app). now in one of the view controllers i need to present the user with the print interaction controller to print images. the thing is i don't use a navigation bar or a toolbar system or otherwise. i have managed to attach a target action method to a custom button. however, apple states that the printing interface should be presented by a system button (the one that looks like an arrow, kind of). question is: is there any way of putting a system icon inside a button that is not inside a (bar)?, or would it be ok to somehow tell the user (with an overlay or something) that tapping the button i'm using (the button is a red ribbon coming down from a picture frame) they will get the printing options?
Apple says:
Although the print button can be any
custom button, it is recommended that
you use the system item-action button
shown in Figure 6-1.
I'd interpret that to mean that you can use your own button if you want to.
You might want to consider having a toolbar at the top of the view for this particular tab. Just appearing on this tab. This would make the issue moot.
You could also, have the tool bar "slide in" and "slide out" from the top to provide access to this (and other?) actions. A single or double tap could instigate such an action.
Unfortunately, Apple doesn't expose the images for the custom bar button items in any reasonable manner. If you'd like access to them, I suggest using the bug reporter system at Apple's developer site to request that.

Resources