iphone sdk - segmentedcontrol.tintcolor not working in OS3 - iphone-sdk-3.0

In my app I have a uisegmentedcontrol in the navigation bar, as the right button item.
the code:
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.tintColor = [UIColor colorWithRed:0.70 green:0.171 blue:0.1 alpha:1.0];
works in OS2 but not OS3...?
ade.
p.s. my base sdk is 3.0

Ok,
I had to do two things:
1) For views that always had the segmentedcontrol I had to set the tint color after adding the segmentedcontrol to the rightbarbuttonitem and move the code to viewDidAppear (I had it in ViewWillAppear)
2) For views that don't always have the segmentedcontrol it looked ugly using viewDidAppear as it sometimes was showing the segmentedcontrol and then removing it (when it shouldn't be shown at all). So I had to here use viewWillAppear but also set the item to nil in viewDidDisappear
ade.

Related

iOS 8 - Modal in Popover

I have a popover with TabBarController in it. In one tab there is a TableViewController with a list of names. And there is a plus button, that has a modal segue to AddCharacterVC for adding new names.
In iOS 7 I do it like this:
AddCharacterViewController *acvc = (AddCharacterViewController *)segue.destinationViewController;
acvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
acvc.modalPresentationStyle = UIModalPresentationCurrentContext;// so it does not take full screen in popover
And in AddCharacterVC I set content size like this:
- (void)viewWillAppear:(BOOL)animated {
CGSize size = CGSizeMake(320, 480); // size of view in popover
if (IDIOM == IPAD && [self respondsToSelector:#selector(preferredContentSize)]){
self.preferredContentSize = size;
}
And it works perfectly.
However, in iOS 8 modal view does not cover the whole popover, leaving TabBar visible. The user can tap on it or not, anyway modal view won't unwind properly.
I've tried:
setting acvc.modalPresentationStyle to UIModalPresentationOverCurrentContext
tried to set TabBar hidden
checked in storyboard that edges of TableVC extend under Bottom Bar and Bottom Bar in Modal View (AddCharacterVC) is set to none
All with no results.
Now the only thing I can think of is to try making modalPresentationStyleCustom and use UIPresentationController (I'm trying to do it now, but I haven't done it before). Am I missing something? Could there be other way to do it? Sorry, I cannot post images here yet. Many thanks in advance!
Ok, so I've set the modalPresentationStile to UIModalPresentationCustom, and used UIPresentationController - I've just copied code from WWDC-14's LookInside project and modified it a bit.
I'm not sure if it was the best solution, but it worked in my case.

Adjust SearchBar size in Navigation Bar when Orientation changes to Landscape iOS7

I'm using a Storyboard where I have a UIViewController embedded in a Navigation Controller. I have placed a SearchBar into the Navigation Controller "replacing" the TextView item with it. It works as expected in portrait.
The problem is when I rotate it to Landscape, where the Searchbar remains in the center and its height seems to be bigger than the Nav Bar.
I have tried configuring the constraints, but it hasn't been successful.
Could you help me please?
Set Constraints to your Search bar.. It will shows the magic.
I fixed it adding the search bar in the title view, this way:
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
[self.searchBar setPlaceholder:#"Buscar Recetas"];
[self.searchBar sizeToFit];
[self.searchBar setDelegate:self];
[self.navigationItem setTitleView:self.searchBar];
Note that I'm not using a search display controller in this case. Search Display Controller already has a property where you can set the search bar in the navigation bar, like this:
self.searchdisplaycontroller.displaysSearchBarInNavigationBar = YES;

UIRectEdgeNone makes NavigationBar and Tabbar darker

I have an iOS 7 app that has a NavigationController inside TabbarController.
I then customize the bars background color
[[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
[[UITabBar appearance] setBarTintColor:[UIColor blueColor]];
It runs fine. But if there's a ViewController that wants not to be covered by the bars, like this
self.edgesForExtendedLayout = UIRectEdgeTop;
Which means this ViewController does not want to be covered by the Tabbar. But it makes the Tabbar darker than normal
I think this is because I use custom color for the bars. How to fix ?
It probably means that the there's nothing to show below the translucent tab bar. Set the tab bar translucent property to NO
#rounak is right, maybe setting the tab or nav bar's translucency to NO tells iOS not to try to put another tab or nav bar under the current one, which makes it darker.
In the viewDidLoad, add this:
self.navigationController.navigationBar.translucent = NO; // if you have a nav
self.tabBarController.tabBar.translucent = NO; // if you have a tab

SKStoreProductViewController title color

How do you change the title color and/or bar tint color in a SKStoreProductViewController?
I'm using the appearance API to set navigation bars to a dark color and the text to white. It changes the title color but not the bar tint color in my SKStoreProductViewController.
I don't think you can. At least not on iOS 7. On iOS 6 you can use the UIAppearance protocol and the SKSPVC will pick up the appearance you set on the UINavigationBar.
As noted on this thread, the SKSPVC is a remote view controller so it's inaccesible programmatically, meaning that you can't set it's appearance directly (or indirectly?).
Do the following to avoid the SKStoreProductViewController to take over a tintColor of value WHITE:
#define kCOLOR_NON_WHITE_COLOR [UIColor darkGrayColor]
// CHANGE ALL TINTING BEFORE WE CREATE An INSTANCE OF THIS BROKEN PIECE
[UIWindow appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UIView appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UINavigationBar appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
[UIBarButtonItem appearance].tintColor = kCOLOR_NON_WHITE_COLOR;
// NOW CREATE THE THING
SKStoreProductViewController *controller = [[[SKStoreProductViewController alloc] init] autorelease];
This draws all the UIBarButtonItems and the UISegmentedControls in this controller in the defined color AFAIK and thus makes the controller more like your apps design.
IMPORTANT: Just do not forget(!!!) to change all the tinting back after you dismissed this controller, otherwise fresh created views in your app might take over the enforced tinting.
UPDATE: As you might already have found out the following to manipulate the appearance does not work:
[UINavigationBar appearanceWhenContainedIn:[SKStoreProductViewController class], nil]
This fix is for iOS 7 & 8 on iOS 6 you have different issues. =)

UINavigationBar tint color flashing in iOS 4

The app I'm working on has a custom nab bar but supports iOS 4.2-iOS 5, so I need to set the UINavigationBar background and tint in this old school way in my app delegate.
#implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
self.tintColor = [UIColor colorWithRed:42.0/255.0
green:164.0/255.0
blue:182.0/255.0
alpha:1.0];
UIImage *img = [UIImage imageNamed:#"navbar_bg.png"];
[img drawInRect:CGRectMake(0.0, 0.0,
self.frame.size.width,
self.frame.size.height)];
}
#end
This works for the most part, but I noticed when the app is first starting, the UIBarButtonItems flash the default navigation bar color for a second before they correct themselves and change color to match the navigation bar. Interestingly, the navigation bar itself uses the background image correctly from the get-go.
To be clear, I'm using setBackgroundImage for UINavigationBar on iOS 5 devices which works as expected so the flash is only in iOS 4.
Anyone have any insight on why this would happen and/or how to fix it?
The bar button items are the wrong color? You can manually set their tint color in viewDidLoad: to the tint color
navigationBar.rightBarButtonItem.tintColor = [UIColor ...]
if you're using a nib file. Otherwise you can do the same thing in loadView: . Either way this code will get executed as part of the initial draw loop so you'll have the proper color without any flashing.
Also for future reference, it's technically incorrect to override a method inside a category. (The latest version of Xcode, 4.3, will give you a warning about this). You should either properly subclass UINavigationBar or do "method swizzling". But that's pretty tough so don't worry about it right now :)
If you call the class with the code referenced in viewDidLoad try moving it to awakeFromNib