Code stopped working after upgrade to iOS 5 - iphone

I had these two lines of code that worked in iOS 4. Following an upgrade to iOS 5, it no longer works.
The code would put a background image on the Navigation bar.
CGImage navban = CGImage.FromPNG(new CGDataProvider("images/banner.png"), null, false, CGColorRenderingIntent.Default);
NavigationController.NavigationBar.Layer.Contents = navban;
I am using MonoTouch. Does this no longer work in iOS 5? If so, is there another way to accomplish it?
Thanks.

The property BackgroundImageForBarMetrics of UINavigationBar should do the trick. It's new in ios5 and supports this scenario without going behind UIKit's back.

Related

xcode 8 auto layout uiimageview problems

I have a Android background and now try to code for iOS.
I use Swift as the language and it works really good so far. Now I am getting some troubles to get my layout to work on different screen resolutions that means different iPhones.
I am using storyboards for my ViewController and for now everything worked well except getting UIImageViews to look the same on each iPhone.
I tried now for 2 whole days with dozens of different approaches to get my layout work, but without any success. If I place a single UIImageView on my layout I am able to set the constraints so that it looks the same on each iPhone. Once I place a UIImageView on top of my first UIImageView it destroys everything. I won´t tell you here what I already tried, because it was a lot and nothing worked for me.
I need really some hint or just someone who could just try it on his Storyboard and tell me how he achieved it to get it work. I am using Xcode 8.2.1.
This is how it should look like (iPhone 7):
This is how it looks on a iPhone 4s --> wrong! Proportions are not the same!
It's need more params and maybe UIStackViews.
https://github.com/OMGHaveFun/exampleAutolayout

Is it possible to fix an iPhone app for iOS6+7 and 3.5 + 4 inch displays without editing code?

At this time I'm trying to edit an app of mine to support iOS6+7 aswell as 3.5+4 inch displays.
However I'm trying to do this without changing the code. And it works fine...for one of my requirements.
First I tried fix the 3.5/4 inch display issue with autolayout/contraints. It worked well but either it looked good with iOS6 or iOS7. And I didn't find a way to fix the iOS6/iOS7 diffrence without adjusting tons of code.
Then I resetted my contraints, disabled autolayout and fixed the iOS6/7 issue via offsets (iOS6/7 Deltas). Worked fine too for resolving the other requirement.
Since you can't use offsets AND autolayout at the same time I'm wondering if it's not possible to fix both problems without either checking iOS version or display size in my code?
I didn't provide code or screenshots because it's a more general question and I'm trying to solve this issue without touching my code. However what I can say is that I'm using .xib files to create the views not knowing if that's a problem too...
Thanks in advance,
blaluma
if your using storyboard with autosizing you can achieve that one

UITextField background behaviour change from iOS 4 to iOS 5

In my app I have a UITextField which is on top of a background image. Under iOS 4 I had to set the backgroundColor property to 'clearColor' in order to make it look right. Under iOS 4 the textfield looks like this...
This is how I want it to look. Now, since upgrading to Xcode 4.3 (iOS 5) when I re-run the same project, the box looks like this...
Grrr. So under iOS 5 I changed the backgroundColor property to 'whiteColor' and it works fine. However now, under iOS 4.x the box looks like this...
Note the ugly white corners! So please, can anyone tell me what I should be doing here in order to get it to look normal under both iOS 4 and iOS 5 (i.e. To look like the first image!).
Many thanks,
Simon
I got the same problem a few days ago. To solve this, I just set the borderStyle and comment the backgroundColor line. Everything just work fine, both iOS4 and iOS5.
// textField.backgroundColor = [UIColor clearColor]; // just leave it, dont't set
textField.borderStyle = UITextBorderStyleRoundedRect;
This is what i did to resolve this issue, you can check the version of iOS running on the device and do the handling accordingly, like this
float version = [[[UIDevice currentDevice]systemVersion]floatValue];
if(version < 5.0)
{
//user clear color
}else
{
//use white color
}
Hope this helps you.
Sometimes you might have to rebuild your project. Also, try and make this in a whole new project to see if it is actually a new change to Xcode, or if it is just that particular project to narrow things down. If you then isolate it to being something wrong with your particular project, try and "do it over" to see if it clicks then. But i see you solved it :=)

iPhone SDK 4.0: Testing if view is displayed

using iPhone SDK 4.0, how does one determine if a UIViewController is currently in the viewDidAppear state (currently visible). I could set a flag but was wondering if there is a better way.
Thanks.
Nope, setting a flag is the best way, as you never know if something is in front of it.
Have fun!

UIActivityIndicatorView doesn't work on iPhone 4 with iOS4

I noticed in one of my apps that the activity indicator doesn't seem to work on an iPhone 4. It works fine on an old iPhone upgraded to iOS 4 just not on an iPhone 4. Does anyone know why it isn't working?
This code should do the job, is that correct;)?
#import <QuartzCore/QuartzCore.h>
...
activityIndicatorInstance.layer.shadowColor = [UIColor grayColor].CGColor;
activityIndicatorInstance.layer.shadowRadius = 1;
activityIndicatorInstance.layer.shadowOpacity = 0.5;
activityIndicatorInstance.layer.shadowOffset = CGSizeMake(0, 1);
oddly it uses a transparent alpha channel on the iPhone 4.
A solution may be to add a kind of background...
I had the same problem, but found that if I coded it rather than using Interface Builder it worked.
If your design allows, you can also use the UIActivityIndicatorViewStyleGray or attempt to add a dark shadow to the activityView's layer.
I solve the problem, in iOS5 the frame size is already set. In iOS4 you need to set the frame size yourself. Hope it helps.