I'm using RKSwipeBetweenViewControllers
to switch between UIViewControllers by swipe, and it's all good, but here is a some strange thing i stuck with(look at the screen):
I made that if you scroll news feed down - navigation title going to hidden, and here is curious thing happening: when navigation title disappear - Status bar changing tint color to black! I just don't understand how it's possible?
I already added to to appDelegate
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
and
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
to every possible controllers, and of course navigation bar style i set to "black" but alas! Can anyone say me how to fix it? I will be really appreciate about it!
I had the same problem. What I did was add
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}
inside the UIViewController.
This is in swift though. I guess you need to override the function.
I have a Navigation Controller with nav bar. The issue I have is I can set the status bar to white, but once the nav bar animates onto the page, they return to black. I've tried using the following with no success:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[UIApplication sharedApplication.setStatusBarStyle = UIStatusBarStyleLightContent;
-(UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
and still the time, batter status, etc return to black. I would be fine with making it completely disappear if no one can figure out what I'm doing wrong lol. Thanks in advance.
Starting with iOS 8 the status bar gets its color from the view controller of the top most view that is currently visible. Try setting the following on the Navigation Controller (assuming the UINavigationController view is the top most view):
<navController>.navigationBar.barStyle = UIBarStyleBlack;
If that doesn't work try adding the override to the top level UIViewController as you did (make sure its the primary view controller contained in your UIWindow.. assuming this is not your UINavigationController..]):
-(UIStatusBarStyle) preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
Also:
In the .plist file for your project, make sure the "View controller-based status bar appearance" is set to YES.
Alternative
If you want your
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
command to have an effect set "View controller-based status bar appearance" to NO in your .plist file. Please note though that view controller based status bars are the wave of the future and some third party libraries (like PSPDFKit) now require this option to be enabled.
Hiding Status Bar
If you want to hide the status bar you can try by setting "View controller-based status bar appearance" to NO in your .plist file. Then add the following code to viewWillAppear of your main view controller:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
I have this issue, where as standard the flipsideviewcontroller UINavigationBar looks like this:
Anybody have any ideas on how to move the UINavigationBar either down, or to stop the ugliness of it all?
It's tricky. :) You need to set a delegate for the UINavigationBar - this will probably be the FlipsideViewController. You can do this in the storyboard, or in code - for example, if you have an outlet to the navigation bar:
-(void)viewDidLoad {
[super viewDidLoad];
self.navigationBar.delegate = self;
}
Now comes the important part: implement in the delegate this method:
- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
return UIBarPositionTopAttached;
}
With auto layout, it is also crucial that the top of the navigation bar have a zero-constant constraint to the Top Layout Guide. This is not entirely easy to set up because there is a bug in Xcode that will try to turn this into a bad constraint from the bottom of the navigation bar. If that happens:
Delete the top constraint.
Move the nav bar down the screen.
Control-drag to form the top constraint to the Top Layout Guide again.
Now select the top constraint and manually set its Constant to 0, to make the nav bar move back up again.
I have an application, which open popover with NSTextField. The text field is not editable. Behavior for text field is set to Editable. I still can paste and copy text to this field but i can't edit it.
Anyone knows, what can be wrong?
Not sure if you still need the answer, but there may be some others still looking. I found a solution on apple developer forums. Quoting the original author:
The main problem is the way keyboard events works. Although the NSTextField (and all its superviews) receives keyboard events, it doesn't make any action. That happens because the view where the popover is atached, is in a window which can't become a key window. You can't access that window in any way, at least I couldn't. So the solution is override the method canBecomeKeyWindow for every NSWindow in our application using a category.
NSWindow+canBecomeKeyWindow.h
#interface NSWindow (canBecomeKeyWindow)
#end
NSWindow+canBecomeKeyWindow.m
#implementation NSWindow (canBecomeKeyWindow)
//This is to fix a bug with 10.7 where an NSPopover with a text field cannot be edited if its parent window won't become key
//The pragma statements disable the corresponding warning for overriding an already-implemented method
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
- (BOOL)canBecomeKeyWindow
{
return YES;
}
#pragma clang diagnostic pop
#end
That makes the popover fully resposive. If you need another window which must respond NO to canBecomeKeyWindow, you can always make a subclass.
I struggled with this for a while as well, until I realized it was a bug.
However, instead of relying on an isActive state of a NSStatusItem view, I find it much more reliable to use the isShown property of the NSPopover you have implemented.
In my code, I have a NSPopover in a NSViewController:
- (BOOL)canBecomeKeyWindow
{
if([self class]==NSClassFromString(#"NSStatusBarWindow"))
{
NSPopover *mainPopover = [[((AppDelegate*)[NSApp delegate]) mainViewController] mainPopover];
if(![mainPopover isShown])
return NO;
}
return YES;
}
Balazs Toth's answer works, but if you're attaching the popover to NSStatusItem.view the status item becomes unresponsive - requiring two clicks to focus.
What i found when working with this solution is that when NSStatusItem becomes unresponsive, you can easily override this behavior like this
- (BOOL)canBecomeKeyWindow {
if([self class]==NSClassFromString(#"NSStatusBarWindow")) {
CBStatusBarView* view = [((CBAppDelegate*)[NSApp delegate]) statusItemView];
if(![view isActive]) return NO;
}
return YES;
}
You will check for the class of the window, if it matches the NSStatusBarWindow we can then check somehow if the NSStatusItem is active. If it is, that means we have to return YES, because this way the NSPopover from NSStatusItem will have all keyboard events.
What I'm using for checking if the NSStatusItem was clicked (or is active) is that in my own custom view i have a bool value which changes when user clicks on the NSStatusItem, system automatically checks for "canBecomeKeyWindow" and when it does it will return NO and after user clicks on it (while it is returning the NO) it will change the bool value and return YES when system asks again (when NSPopover is being clicked for NSTextField editing).
Sidenotes:
CBStatusBarView is my custom view for NSStatusItem
CBAppDelegate is my App Delegate class
If anyone is still looking for an answer to this, I am working in Swift.
At the time where you wish the field to allow text entry, I have used myTextField.becomeFirstReponder()
To opt out; just use myTextField.resignFirstResponder()
Definitely a bug. That bug report is exactly what I was trying to do. Even down to creating the status item and overriding mousdown.
I can confirm that Balazs Toth's answer works. I just wonder if it might get in the way down the road.
If someone gets it and the solution above didn't do the trick for him.
The problem in my app was in the info tab in the targets my application was set to
Application is background only = true
and shulde of been
Application is agent = true
Spent an entire day on this thing.
Bug. http://openradar.appspot.com/9722231
I had a problem with the splitView so I decided to make my own version of it using a ViewBasedApplication. The view is set up to be like a splitView, but instead of having the static table when you flip it to landscape it will have the popover control like it normally does in the portrait mode.
I have everything set up, but I'm encountering an error when I select an item from the popover table. It isn't updating the view to go to the appropriate page that was selected in the table...the code for the setDetailItem in the ViewController.m file looks like this:
-(void)setDetailTime:(id)newDetailItem{
if(detailitem != newDetailItem) {
[detailitem release];
detailItem = [newDetailItem retain[;
[self configureView];
...
}
The problem is in the [sef configureView] line. it says that "PDFViewController" may not respond to '-configureView'. Im assuming this is because '-configureView' is specific to only the SplitView. Any ideas of a way to workaround this issue?
Thanks!
Your class PDFViewController does not have a configureView method, which is why you're getting the warning (and why you're not seeing anything happen).
You probably need to instead call [self.view setNeedsDisplay] which basically tells the view to redraw itself. I don't know if this will work for you, because I don't know how the rest of your class is written.