myApp[12345:678] Could not load the "image.png" image referenced from a nib in the bundle with identifier "com.company.app"
Showing posts with label UIImage. Show all posts
Showing posts with label UIImage. Show all posts
Tuesday, February 28, 2012
Could not load the image referenced from a nib in the bundle with identifier
Just make sure your files are where you (your project file) thinks they are.
Check for filenames in red (at left), indicating that somehow some file became unknown. Maybe you were moving files around in Finder, were you? Of course you were, you silly bugger!
Wednesday, September 21, 2011
How to Create Custom Background for UINavigationBar
Needed a custom background for UINavigationBar (pre-iOS5). First tried placing an UIImageView under "Black Translucent" UINavigationBar, but there were some problems:
Labels:
CGContextFillRect,
CGContextRef,
drawRect,
UIColor,
UIImage,
UINavigationBar
Thursday, November 11, 2010
How to Center UIImage On-Screen
Created dynamically an UIImageView with small UIImage at top left corner. Wanted it centered, but UIImage automagically resized UIImageView, which was by default stuck at that forementioned top left corner.
UIImage *image = [UIImage imageNamed:@"small.png"];There are several ways to fix this, some more complicated while some more difficult. Common thing is that they contain a lot of code to infest with bugs. However simple problems require simple solutions:
self.imageView = [[UIImageView alloc] initWithImage:image];
self.imageView.center = self.view.center;I'm too embarrassed to tell how much time I "invested" until I got to this solution. Let's just say that I learned a lot. Btw this code does not rotate. There are several ways to fix this...
[self.view addSubview:self.imageView];
Monday, October 11, 2010
How to Find Out Width of Truncated UILabel Text
Found out my tip "How to Float an Icon after UILabel" worked only in positive scenarios. If your text string is longer than UILabel width, icon could have been pushed out of sight. In worst case nobody would ever have seen the icon!
// TitleSome measurements of different methods, just to check what is available:
label = (UILabel *)[cell viewWithTag:1];
label.text = @"This is a very long title which is too long";
// Icon
image = (UIImageView *)[cell viewWithTag:10];
image.image = [UIImage imageNamed:@"logo.png"];
CGSize frame1 = label.frame;Next icon positioning. Here you should have calculations to compensate for different icon sizes (in case all of your icons are not same size):
// 205x21
CGSize frame2 = [label sizeThatFits:label.frame.size];
// 291x19
CGSize frame3 = [label.text sizeWithFont:label.font constrainedToSize:label.frame.size];
// 163x19
CGSize frame4 = [label.text sizeWithFont:label.font constrainedToSize:label.frame.size lineBreakMode:label.lineBreakMode];
// 203x19
CGSize frame5 = [label.text sizeWithFont:label.font forWidth:label.frame.size.width lineBreakMode:label.lineBreakMode];
// 203x19
// Icon positioningOk, now that's perfect (until next defect report)!
CGSize frame = image.frame;
frame.origin.x = label.frame.origin.x + frame5.width + 4;
image.frame = frame;
Labels:
CGSize,
icon,
iphone,
sizeThatFits,
sizeWithFont,
UIImage,
UIImageView,
UILabel,
viewWithTag
Wednesday, October 6, 2010
How to Float an Icon after UILabel
Want to place a floating icon right after a variable lenght text string - using Interface Builder? Wonderful helper that IB tool or so I thought...
First create a UITableViewCell template with IB, put there a fixed lenght UILabel followed by a UIImageView. No problems, their values are easy to setup at cellForRowAtIndexPath with view tag id numbers:
I had a problem that Interface Builder wanted to set UITableViewCell tag same as my image tag. No errors, no warnings, no indications of problem - except that I couldn't get my image frame no matter how much I banged head into brickwall! Removing tag didn't help, it just automagically came back. Ouch!
First create a UITableViewCell template with IB, put there a fixed lenght UILabel followed by a UIImageView. No problems, their values are easy to setup at cellForRowAtIndexPath with view tag id numbers:
UILabel *label = nil;But how to "float" that image right after text string? UILabel is fixed sized, so that won't help. Have to check the size of label.text instead:
UIImageView *image = nil;
CGRect frame;
// Title
label = (UILabel *)[cell viewWithTag:1];
label.text = @"Title text";
// IconThat's it, very simple! Just beware that your tag numbers MUST be unique.
image = (UIImageView *)[cell viewWithTag:10];
image.image = [UIImage imageNamed:@"logo.png"];
// Icon positioning
frame = image.frame;
CGSize f = [label sizeThatFits:label.frame.size];
frame.origin.x = label.frame.origin.x + f.width + 4;
image.frame = frame;
I had a problem that Interface Builder wanted to set UITableViewCell tag same as my image tag. No errors, no warnings, no indications of problem - except that I couldn't get my image frame no matter how much I banged head into brickwall! Removing tag didn't help, it just automagically came back. Ouch!
Labels:
CGRect,
imageNames,
interface builder,
iphone,
sizeThatFits,
UIImage,
UIImageView,
UILabel,
UITableViewCell
Tuesday, May 25, 2010
How to Create Custom Map Annotation Button
Custom accessory button for MKPinAnnotationView right side, create inside MKMapViewDelegate protocol mapView:viewForAnnotation method:
Usually sample codes use UIButtonTypeDetailDisclosure as right button, but you can't use that unless you really show additional details. For anything else, you must use a custom button.UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 20)]; [button setImage:[UIImage imageNamed:@"myButton.png"] forState:UIControlStateNormal]; view.rightCalloutAccessoryView = button;
Labels:
accessory,
delegate,
iphone,
map,
MKMapViewDelegate,
MKPinAnnotationView,
UIButton,
UIButtonTypeDetailDisclosure,
UIImage
Subscribe to:
Posts (Atom)