UIView above UIAlertView - ios

In my app, a lock screen is used. Sometimes a UIAlertView is shown, now when the user sends the app to the background and brings it in front again, the UIAlertview is shown above the lock screen. Is there a possibility to add a UIViewController's view above everything, i.e. above the UIAlertView?

You should have like this
UIWindow *mySpecialWindowForLockScreen = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
//"Hey iOS Please put this window above all alert view"
mySpecialWindowForLockScreen.windowLevel = UIWindowLevelAlert+100;
UIViewController *lockScreenViewController = [[UIViewController alloc]init];//Lock Screen
lockScreenViewController.view.frame = mySpecialWindowForLockScreen.bounds;
mySpecialWindowForLockScreen.rootViewController = lockScreenViewController;
// In lockScreenViewController view you can add lock screen images and other UI stuff
mySpecialWindowForLockScreen.rootViewController.view.backgroundColor = [UIColor greenColor];
[mySpecialWindowForLockScreen makeKeyAndVisible];
Whenever you want to hide the LockScreen window then simply hide it by setHidden:YES.

There are three kind of UIWindowLevel, the biggest one will be shown above the other window.
So I suggest you use a UIWindow to create your lock screen and let it's window level bigger than UIWindowLevelAlert,
Basically, their values are :
UIWindowLevelNormal = 0.000000;
UIWindowLevel UIWindowLevelAlert = 2000.000000;
UIWindowLevel UIWindowLevelStatusBar = 1000.000000;
so that's why the alert view will show above the other window.have a try.

Related

Re-enable mirroring on iOS

In my iOS app I need to display custom content on external display (using AirPlay) as well as mirroring some screens on TV.
For presenting custom content I use code from Multiple Display Programming Guide for iOS and it works well: while my iPad is in 'mirror' AirPlay mode I'm able to show some stuff on the TV. However, documentation says6
To re-enable mirroring after displaying unique content, simply remove the window you created from the appropriate screen object.
And this part isn't working at all. I just cannot destroy my window that I use to display content on external screen. Here's the code:
- (void) destroySecondWindow{
if (secondWindow){
for( UIView* view in secondWindow.subviews ){
[view removeFromSuperview];
}
secondWindow.backgroundColor = [UIColor clearColor];
secondWindow.hidden = YES;
// Hide and then delete the window.
[secondWindow removeFromSuperview];
secondWindow = nil;
}
}
As far as unique content should be displayed only when one particular view controller is visible, I'm trying to destroy external window like this:
- (void) viewWillDisappear:(BOOL)animated{
[self destroySecondWindow];
}
Here's how I create second window:
- (void) createSecondWindowForScreen:(UIScreen*)screen{
if( screen == nil || secondWindow != nil ){
return;
}
CGRect screenBounds = screen.bounds;
secondWindow = [[UIWindow alloc] initWithFrame:screenBounds];
secondWindow.backgroundColor = [UIColor blueColor];
secondWindow.screen = screen;
[secondWindow setHidden:NO];
}
So the question is: does anybody know how to re-enable screen mirroring after displaying unique content on TV?
Thanks in advance!

Adding subviews on UIWindow covers the keyboard called by textfields

I am trying to imitate an alert view and i show a view with two text fields above a view with a translucent background. The problem is that when i try to tap on the text fields , the keyboard is shown behind my translucent view and i can't tap it no more. Is there a solution?
Here is my code:
if (_grayView==nil) {
_grayView = [[UIView alloc]init];
_grayView.frame = [[UIScreen mainScreen]bounds];
_grayView.backgroundColor = [UIColor blackColor];
_grayView.alpha = 0.7;
[[[[UIApplication sharedApplication] windows] lastObject] addSubview:_grayView];
}
//Show the dimensions view when choosing an image
_dimensionsView.hidden = NO;
[[[[UIApplication sharedApplication] windows] lastObject] addSubview:_dimensionsView];
In the _dimensionsView i have the textfileds.
What you're doing isn't a very good idea to begin with. Also be aware that you can't count on windows.lastObject to always be the window you expect. iOS 7 and 8 are more and more liberal with creating new windows for keyboards and modals. You might not be adding your subview to the window you're expecting.

iOS app UI has been pushed down due to Call Notification

Here is the scenario.
Before launching my app, I make a phone call. Then I open my app, the status bar height has doubled due to call notification. and because of that, the entire UI of my app has been pushed down by additional 20pt. Switching back to phone app and end the call, when I open my app again, the UI gets stuck as just now, except that the green notification bar's gone, leaving an additional 20pt black bar on top.
This does not happen if my app is already launched before I make the call.
I've used [self.window makeKeyAndVisible];
Any idea how to adjust UI properly in this case?
Update:
Here's the code
ADTransitionController *transitionController= [[ADTransitionController alloc] initWithRootViewController:[[MainViewController alloc] init]];
transitionController.wantsFullScreenLayout = YES;
ConfigurationSetupViewController *menuController = [[ConfigurationSetupViewController alloc] init];
REFrostedViewController *frostedViewController = [[REFrostedViewController alloc] initWithContentViewController:transitionController menuViewController:menuController];
frostedViewController.direction = REFrostedViewControllerDirectionLeft;
frostedViewController.liveBlurBackgroundStyle = REFrostedViewControllerLiveBackgroundStyleLight;
if ([GBDeviceInfo deviceDetails].majoriOSVersion < 7) {
frostedViewController.blurRadius = 2;
}
self.window.rootViewController = frostedViewController;
I've drilled down the problem with REFrostedViewController. If I set rootViewController to transitionController, the layout is perfectly aligned.
Update2:
So the fact is.. when a double status bar is present, ADTransitionController will set coordY = 20 and height = 548. REFrostedViewController does the same thing.. causing I have 40 margin on top.. One thing I'm not sure is.. when is the frame of these UIViews being set?

Moving Particle View to Front of Screen?

I currently have a particle view connected to storyboard. The problem that I'm facing is that I'm displaying an alert at the same time I show this view, and the alert is always shown in front of the particle view. Is there a way where I can always place the particle view in front? I'm using a third party alert library titled SIAlertView, so I'm assuming it may be possible.
I've logged the zPosition of the alertView and it's always 0, so I set the zPosition of my particle view's layer to 10, but it is still shown beneath the alert view.
Here's the storyboard hierarchy:
I do not know about SIAlertView but normal UIAlertView is shown via separate window. If you want to overlap it you can not do it by changing zpozition, you have to also use a separate window:
// do not forget to keep strong reference for it somewhere!
UIWindow *notificationWindow;
//your frame here!
notificationWindow = [[UIWindow alloc] initWithFrame: some_cgrect];
notificationWindow.backgroundColor = [UIColor clearColor]; // your color if needed
notificationWindow.userInteractionEnabled = NO; // if needed
// IMPORTANT PART!
notificationWindow.windowLevel = UIWindowLevelAlert + 1;
notificationWindow.rootViewController = [UIViewController new];
notificationWindow.hidden = NO; // This is also important!
UPDATE:
To overlap also a status bar use
notificationWindow.windowLevel = UIWindowLevelStatusBar;
to dismiss UIWindow just invalidate strong pointer to it. Something like:
self.strongPointerToYourWindow = nil;

iPad view layout similar to facebook

How would one go about creating an ipad app that has a similar view layout to the facebook app? That is, one big view in the center, and the smaller, menu-like controller on the left side gets visible when you slide the main view to the right?
Are they using a modified splitview layout, or is this a custom multi-layer layout?
I know that I probably must make use of some gesture recognizers, but can anyone point me into the right direction of how to remake the facebook app layout? E.g what would be the two main controllers (tableview on the left, custom view in fullscreen size in the middle, place above the tableview?), and how do i slide in/out the menu?
Thanks in advance
as a note: I only need landscape orientation, should make thins easier.
[edit] this is my current implementation with the viewdeckcontroller:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController* menu = [[RootViewController alloc] init];
UINavigationController* navController= [[UINavigationController alloc] initWithRootViewController:menu];
DetailViewController* center = [[DetailViewController alloc] init];
IIViewDeckController* rootController = [[IIViewDeckController alloc] initWithCenterViewController:center leftViewController:navController];
_menuController = rootController;
rootController.leftLedge = [[UIScreen mainScreen] bounds].size.width - 50.0;
self.window.rootViewController = rootController;
[self.window makeKeyAndVisible];
This is the rootviewcontroller class (left side menu-thing controller):
-(void)loadView
{
// [super loadView];
// self.tableView = [[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped] autorelease];
self.view= [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320, 704)];
UITableView* tableView= [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
[self.view addSubview:tableView];
self.tableView= tableView;
}
This is a drop-in Xcode project for exactly what you want. :)
https://github.com/devindoty/DDMenuController
IIViewDeckController implements sliding views (like in the Path and Facebook apps) and also supports rotation.
I know this could be a bit late.
Hard to be certain this is what you mean but for the width of your left slide out view, you can control how much of it is shown by modifying the leftLedge property to how many pixels from the edge should be covered by the centerViewController. ie. leftLedge=50 would make your left menu 320-50=270 visible, leftLedge=250 would make your left menu 320-250=70 visible. This is visible width not actual width.
In your appDelegate
IIViewDeckController *deckController = [[IIViewDeckController alloc] initWithCenterViewController:self.mainNavigationController leftViewController:self.sideMenuViewController];
deckController.panningMode = IIViewDeckNavigationBarPanning;
deckController.leftLedge = 50;
deckController.centerhiddenInteractivity = IIViewDeckCenterHiddenNotUserInteractiveWithTapToClose;

Resources