Hiding iOS Status Bar's Text - ios

This question is not about hiding the status bar, but merely hiding the text of the status bar.
I could nt find it anywhere to approach this problem
UBER app does this, when we open the side menu in uber, the status bar text disappear,

No you can't hide text of status bar. you can hide status bar with animation something like,
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
[UIView animateWithDuration:0.7 animations:^{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
// self.navigationController.navigationBar.frame = self.navigationController.navigationBar.bounds;
self.view.window.frame = CGRectMake(0, 0, appFrame.size.width, appFrame.size.height);
}];
It is in obj c and just for understand concepts, convert in swift!
You can add new view instead of status bar as custom status bar look
Hope this will help :)

int itemToHide = 0;
[[objc_getClass("SBStatusBarStateAggregator") sharedInstance]
beginCoalescentBlock];
[[objc_getClass("SBStatusBarStateAggregator") sharedInstance]
_setItem:itemToHide enabled:NO];
[[objc_getClass("SBStatusBarStateAggregator") sharedInstance]
endCoalescentBlock];
please check this link. it's may help you.

Related

bad orientation in screen with multiple viewcontrollers/ views in iOS 7, landscape only (iOS 8 is fine)

I'm using TheSidebarController to implement add a sliding menu into an iOS application. This is the library I'm using, but I've found the same issue in other libraries, like ECSlidingViewController, etc. They essentially work by adding multiple view controllers onto a containing view controller, nothing too crazy.
The issue is, when you make the app a landscape app, all the screens in the container- the menu, the content screen- seem to think they're in portrait mode, and get cut off half way. You can see the issue in this screenshot where the table is cut off:
http://imgur.com/xD5MUei
I've been trying to get this to work in any way I can, and no luck.
The library I'm using + example project can be found here:
https://github.com/jondanao/TheSidebarController
Any help is greatly appreciated :)
EDIT: people are saying I can stretch the table out to make it look normal, but this just masks the underlying problem, which is the app and/or the screens still think they're in portrait orientation. As a quick example, if I take the example project, and in LeftViewController substitute the following code:
- (void)dismissThisViewController
{
UIViewController* vc = [[UIViewController alloc] init];
UINavigationController* pulldown = [[UINavigationController alloc] initWithRootViewController:vc];
pulldown.view.frame = CGRectMake(pulldown.view.frame.origin.x, -[[UIApplication sharedApplication] delegate].window.frame.size.height,
pulldown.view.frame.size.width, pulldown.view.frame.size.height);
[[[UIApplication sharedApplication] delegate].window addSubview:pulldown.view];
[UIView animateWithDuration:.5 animations:^{
pulldown.view.frame = CGRectMake(pulldown.view.frame.origin.x, 0,
pulldown.view.frame.size.width, pulldown.view.frame.size.height);
} completion:^(BOOL finished) {
;
}];
}
The viewcontroller comes in sideways, not from the top.
This was a strange one... I had to set the frame of the content view controller, which made sense, but then I had to reset it every time the content was refreshed:
- (void)setContentViewController:(UIViewController *)contentViewController
{
// Old View Controller
UIViewController *oldViewController = self.contentViewController;
[oldViewController willMoveToParentViewController:nil];
[oldViewController.view removeFromSuperview];
[oldViewController removeFromParentViewController];
// New View Controller
UIViewController *newViewController = contentViewController;
[self.contentContainerViewController addChildViewController:newViewController];
[self.contentContainerViewController.view addSubview:newViewController.view];
[newViewController didMoveToParentViewController:self.contentContainerViewController];
_contentViewController = newViewController;
if ([DeviceDetection isDeviceiPad]) {
_contentViewController.view.frame = CGRectMake(0, 0, 1024, 768);
}
}
Did you check if it's has something to do with the new interface orientation?
https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html
chapter -> Supporting New Screen Sizes and Scales
In CenterViewController.h make the class a subclass of a UITableViewController instead.
Then comment out [self.view addSubview:self.tableView]; in CenterViewController.m.
Done!
In centerViewController.m, when you create the tableview, add this line:
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

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.

Opaque white status bar in iOS7

First off, I'm aware that the two well know ways of modifying the status bar are
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
and
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
However, with the default style, the status bar has black text with a clear (or translucent white - I can't tell) background. A view in my application slides up at certain points, and it is viewable through the status bar. Is there a way to make the status bar background an opaque white color?
Thanks
I solved this by creating a Base View Controller that each VC inherits from, and adding the following to viewDidLoad:
//Make status bar opaque
CGRect blocker = CGRectMake(0, 0, self.view.frame.size.width, 20);
ColoredLineSegment *blockerView = [[ColoredLineSegment alloc] initWithFrame:blocker]; //ColoredLineSegment is just a colored in rect
blockerView.color = [UIColor whiteColor];
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubview:blockerView];
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] bringSubviewToFront:blockerView];
Try this in AppDelegate.m :
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0/255 green:255.0/255 blue:255.0/255 alpha:1.0]];
It should work !

UIStatus Bar Color issue

For showing status bar in iOS 7 did the following code :-
- (void) viewDidLayoutSubviews
{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0"))
{
CGRect viewBounds = self.view.bounds;
CGFloat topBarOffset = self.topLayoutGuide.length;
viewBounds.origin.y = topBarOffset * -1;
self.view.bounds = viewBounds;
}
}
As you can see in the image status bar color changes for both iOS Simulator 3.5 inch (iPhone 4/4s) and 4 inch (iPhone 5) .I want to show my status bar color white in 3.5 inch screens also. So, Please help me out from this issue.
Thanks in advance.
Go in your PLIST, and add this flag:
View controller-based status bar appearance = NO
next, in your AppDelegate in didFinishLaunchingWithOptions add this:
[[ UIApplication sharedApplication ] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES ];
after checking if your device is ios7. UIStatusBarStyleLightContent is new.
Hope this helps.

Positioning MPMoviePlayerController view

I got a little problem when trying to position the view of a MPMoviePlayerController. Here is my code so far.
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[[NSURL alloc] initFileURLWithPath:URL]];
moviePlayerController.shouldAutoplay = NO;
[moviePlayerController.view setFrame:CGRectMake((CGFloat)vidX, (CGFloat)vidY, (CGFloat)vidWidth, (CGFloat)vidHeight)];
//Find ApplicationWindow
id delegate = [[UIApplication sharedApplication] delegate];
UIWindow * win= [delegate window];
[win addSubview:moviePlayerController.view];
The code works fine and the movie is shown. However the positioning is making me crazy. When I change the width or the height of the view I expect the view to stay at the exact x and y position and only width and height should change. But this is not the case. When I change vidWidth or vidHeight and leave vidX and vidY untouched the origin of the view jumps to another point, which makes it extremely hard to position the video view.
Any help will be appreciated.
Best Regards,
Rambazamba

Resources