Set statusbar to hidden in C4 - statusbar

Since iOS7 I have had a hard time hiding the status bar in apps. I've tried most of the tricks in another thread on SO and I am still unable to hide the status bar. How might I do this in C4?

As per that question, there's a trick listed as one of the answers that states:
- (BOOL)prefersStatusBarHidden {
return YES;
}
You'll want to add this to your workspace.

Related

iOS7 how to completely hide status bar throughout app?

I'm building a sprite kit game, and normally status bar does not show within my app. However, the drag and drop code that I'm using is doing something with the window and when the item is being dragged, the status bar flickers on and off. So my question is:
How can I completely and utterly tell iOS7 to hide status bar everywhere within my app?
I tried plugging per controller code, but cannot seem to find which particular controller is showing the status bar.
- (BOOL)prefersStatusBarHidden
{
return YES;
}
I have status bar set to initially hidden in plist:
I tried using setStatusBarHidden within appDidFinishLaunching
Maybe there's some centralized setting I can set to off?
The setStatusBarHidden setting and the "Status bar is initially hidden" Info.plist setting do not work unless you also set the "View controller-based status bar appearance" Info.plist key (UIViewControllerBasedStatusBarAppearance) to "NO".
In other words, either you're doing this at the level of every single top-level view controller or you're doing it at the global UIApplication level, and this key determines which it is.
However, it is better to learn to do it the view controller way, because Apple might eventually take away the option to do it at the global UIApplication level.

Double tap UISearchBar with search delegate on iOS 7 causes UISearchBar to disappear

We have a search bar in the table header. When the user taps on it twice quickly on iOS 7, it disappears. Does anyone have any suggestions what we are doing wrong?
After lots of trial and errors, I found that when searchDisplayController ends search, searchbar gets disappear, so I have reinserted the searchbar to table header and it worked for me.
- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller
{
self.searchingFetchedResultsController = nil;
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
[self.tableView insertSubview:self.searchDisplayController.searchBar aboveSubview:self.tableView];
}
return;
}
Hope this helps.
(I posted this same answer to Troubles with UISearchBar \ UISearchDisplayViewController, which seems like a duplicate of this question.)
I encountered the same issue, and noticed that searchDisplayControllerDidEndSearch was being called twice. The first time, the superview of self.searchDisplayController.searchBar is the UITableView, and the second time it's still a UIView.
With Priya's answer, I worry about unintended consequences or unneeded overhead from re-inserting the subview every time the search bar is double-tapped, and I also worry about it breaking with future iOS versions. Fortunately, we can take advantage of the superview strangeness like this:
- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller {
if (self.tableView != self.searchDisplayController.searchBar.superview) {
[self.tableView insertSubview:self.searchDisplayController.searchBar aboveSubview:self.tableView];
}
}
If I had to guess what was happening, the UISearchBar is automatically creating a temporary UIView as its superview when it's active – this is the view seen when the search is being performed. While the UISearchBar is being dismissed, the superview gets set back to be the UITableView it had before, unless it gets dismissed so quickly that it was never properly initialized, in which case it cleans up improperly and the UITableView never gets the UISearchBar back as its child.
This solution still isn't ideal, and I think Apple must be doing something different in its own apps because their search bar UX feels a bit better. I think it would be better not to handle the second tap in the first place until the UISearchBar was ready. I tried using the other UISearchBarDelegate methods to do this, but I couldn't find an appropriate hook to override the current behavior.

Is there any way to highlight the status bar item programmatically?

I'd like to perform the following:
when I click on the status bar item (NSStatusItem) I want to highlight it (no menu) indefinitely and when the application loses focus I want to stop highlighting it.
Is there any way of doing this? I can't find it, tbh.
You can probably do this with a custom view that sends the status item a drawStatusBarBackgroundInRect:withHighlight: message.
I doubt there's any way to do it without a custom view, since, as I mentioned in my comment on the question, keeping the item highlighted when the user doesn't have the mouse down on it looks bad.
Old question, but I think it is worth adding this alternative answer.
This will not automatically un-highlight when the application loses focus, but this allows you to highlight without using a custom view (as the other answer requires):
NSStatusItem *statusItem = [self getStatusItem];
[statusItem.button setHighlighted:YES];
You can unhighlight it manually using the same method:
[statusItem.button setHighlighted:NO];
Note I got this answer from a similar question here.

Custom Annotation View do not work on iOS6

I'm using the J4n0 Callout code (github) to implement a custom annotation in MapKit.
It was working just fine on iOS5. But on iOS6 I have 2 problems:
Annotations are displayed over the AnnotationView (see picture 1).
The first Click on an Annotation opens the AnnotationView just fine, but the second click opens an annotation with a bad size (see picture 2).
Does anyone using this library have some similar problem/solution?
I can give some code if needed!
If annotations are displayed over the AnnotationView try to code:
- (void)didMoveToSuperview {
[super didMoveToSuperview];
[self.superview bringSubviewToFront:self];
}
Just in case above solution doesn't work try
view.layer.zposition = 1
I am not sure whether you used the same code as mine, I downloaded it from somewhere to custom the annotationView and I also figured out that in the second time, the size is incorrect. I had noticed that the removeAnnotation function, will also make the annotationView call its didMoveToSuperview once again! Then I dug into the codes in didMoveToSuperview and found that the codes that I downloaded (i hope u meet the same one), do some animation in it so this will make the animation codes call twice. That makes the problem that "second click open an annotation with a bad size"
So remove this animation codes, or make it call somewhere else and NOT in didMoveToSuperview but properly. I hope this will help you, and hope you will share your advice if find out that I am wrong.

Force the keyboard to become visible and stay visible in view

I want to have the virtual keyboard appear in my view on load and I want it to say visible for the lifetime of the view. There is a text field and I treat as the primary control for this view.
Initially, I called [self.textField becomeFirstResponder] in -viewWillAppear: following advice I've gotten here. Then, I came up with a different idea: I overloaded UIViewController's -becomeFirstResponder.
- (BOOL)becomeFirstResponder
{
if (self.primeResponder)
return [self.primeResponder becomeFirstResponder];
return [super becomeFirstResponder];
}
I'm not seeing any hidden problems with this, but then again, no one recommends it either. Am I missing something? Is this a bad approach? Please help.
In reviewing my old question, I thought now would be a good time provide an answer to this.
It works and does not have any major drawbacks.
I've had good luck with this method except in a peculiar circumstance. I used this to set a text field in a table view cell as the prime responder. In iOS 6, it didn't load the keyboard or highlight the textfield when the view was pushed onto the navigation controller stack.
See In iOS 6, -[UITextField becomeFirstResponder] doesn't work in -viewWillAppear: for my solution to that problem.