UIActivityIndicatorView doesn't work on iPhone 4 with iOS4 - iphone

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.

Related

trouble with rounded rectangles in Xcode 6

I'm a noob having trouble rounding the corners of my buttons using interface builder in Xcode 6.
I added a new User Defined Runtime Attribute (layer.cornerRadius) as per the below instructions:
https://stackoverflow.com/a/25164977/2903220
Unfortunately when I run the app there is no change in the button.
All other answers I've found say to do the same thing, yet it's not working.
My questions is are there other settings I should check which may cause this to not work?
(maybe it's better to do it programatically?!)
Please help! Thanks!
button.clipsToBounds = YES;
button.layer.cornerRadius = 20;//half of the width
button.layer.borderColor=[UIColor redColor].CGColor;
button.layer.borderWidth=2.0f;
Checking Clip Subviews in the attributes inspector solves the issue.

Code stopped working after upgrade to iOS 5

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.

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 :=)

colorWithPatternImage with iPhone 4 Retina Display (image#2x.png)

Thanks to SO's search function blowing up whenever I enter "#2x", it's difficult to tell whether this has already been asked...
I've been using colorWithPatternImage: to build tiled background images for my various views. However, these predictably look like trash when viewed on the new iPhone 4 display. So I've built #2x versions of my tile.png files, yet colorWithPatternImage: evidently can't properly handle UIImages with double the scale.
Has anyone effectively developed a workaround for this issue? Perhaps within the CoreGraphics framework (of which, I'm quite the novice)?
I believe this is a bug with the SDK. colorWithPatternImage: is doing strange things with the HD image. There's a small thread on the Apple Dev Forums on it, but basically I think it's a bug. Not sure if Apple are aware of it just yet.
I've worked around it by drawing the pattern in a subclass of the view within -drawRect:.
Hope this helps.
- (void)drawRect:(CGRect)rect {
[[UIImage themeImageNamed:#"UIBackgroundPattern.png"] drawAsPatternInRect:rect];
}

CALayer or UIView backgroundColor UIImage on iOS 4

Good day all;
I am not sure what has changed to prevent this from working. On iOS 3 SDK, the following code worked fine in a CATiledLayer class:
- (void)drawInContext:(CGContextRef)context {
UIImage* image = [[ResourcesManager sharedResourcesManager] getUIImageFromArray:Image_Cell_Background Index:[mazeCell zone]];
UIColor* color = [[UIColor alloc] initWithPatternImage:image];
[self setBackgroundColor:[color CGColor]];
[color release];
However, compiling for iOS 4 and executing on simulator fails to render the image. I am baffled especially since images added as sublayers render just fine. Only the background doesn't render.
OK after spending a few days on this I have come up with a work-around.
Firstly, I tried doing this in a UIView and still had the same issues. I then tried other types of GUI components that have a backgroundColor property.
They all produced the same issue. From what I can tell, this appears to be a bug and something to do with the new image loading / caching process implemented that interprets whether or not to use HD or SD graphics.
Basically, the workaround it to load the background image as subview or sublayer (depending on your implementation) and either send it to the back (bottom of the hierarchy) or load it first before any other subview/sublayer.
Perhaps backgournd images in IOS 3 wherey doing this within the view/layer and that perhaps Apple decided not double handle the background image versus subview/sublayer and removed support for it.
However, at least you can set the background to a color or even a transparent color. I have verified this.
At any rate, use this workaround until either apple explains why they made this decision or fix the SDK so that it does handle it. I am keen to learn what the apple developer forums have said about this issue (I am certain it has been raised). I am not part of the program just yet as I am still in the alpha stage, once I get to beta, I will register.