Images on apple watch - ios

I ran into a problem yesterday when my application was rejected. Apparently the images are not being displayed on the actual Apple Watch, however they are being displayed in the simulator. I even tried resetting the simulator and can't replicate the problem that occurred for the apple employee. So I am just wondering what the correct way to add/display images on the apple watch is, such so that they will be displayed properly on the actual hard device?
Code:
.h
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageHeliLeft;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageHeliRight;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageHeliCenter;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsTL;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsTM;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsTR;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsML;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsMM;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsMR;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsBL;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsBM;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsBR;
.m
When I actually set an image programmatically
[self.imageHeliLeft setImageNamed:#"helicopter_1"];
Other wise I used the interface builder to set the image

Here is the answer. I cannot disclose why I know this, but this is what you need to do.
Remove all images from your Watch App target.
Added images to an image asset file that is in your Watch App target.
Reference the images by the name in the asset file.
If you can see the images in the simulator and they are not in your Watch App target and they are in an asset file then they will work for the reviewer.

As of Xcode 6.3, iOS 8.3:
Leave off the ".png" part of the image name. It will look strange in the storyboard, showing a blue "?", instead of the image thumbnail, but will work on both the simulator and watch. Same goes for specifying PNGs for Context Menus and programmatically specifying animation.

If you're setting the images in your extension code, you should add all the images to the extension target too.

Verify the filenames are correct and the images are placed in the correct target's asset library.
WatchKit Images
It is recommended that you place image resource files in the bundle of your WatchKit app (not in your WatchKit extension’s bundle). Placing them in the WatchKit app bundle lets you use the setImageNamed: method of this class to specify the animated image. Setting them using that method offers better performance by eliminating the need to transfer the images from the user’s iPhone to the Apple Watch. The other methods for setting an image must wirelessly send the UIImage object or image data that you provide to Apple Watch.

Related

Why Xcode 9 creates my outlet (strong, nonatomic) by default

When I control-drag outlet from the storyboard, I got the strong property by default. I'm using Xcode 9.4.1. The following code is what it looks like. Is it because of XCode Swift compatibility as in Swift it makes sense to create strong.
#property (strong, nonatomic) IBOutlet UILabel *lbl
The default value should be weak, but if you once change it manually to strong as shown in the photo, the default value changes to strong, so you need to manually put it back to weak.

Apple Watch .png images loading in simulator but not on device for Apple [duplicate]

I ran into a problem yesterday when my application was rejected. Apparently the images are not being displayed on the actual Apple Watch, however they are being displayed in the simulator. I even tried resetting the simulator and can't replicate the problem that occurred for the apple employee. So I am just wondering what the correct way to add/display images on the apple watch is, such so that they will be displayed properly on the actual hard device?
Code:
.h
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageHeliLeft;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageHeliRight;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageHeliCenter;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsTL;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsTM;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsTR;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsML;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsMM;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsMR;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsBL;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsBM;
#property (strong, nonatomic) IBOutlet WKInterfaceImage *imageObsBR;
.m
When I actually set an image programmatically
[self.imageHeliLeft setImageNamed:#"helicopter_1"];
Other wise I used the interface builder to set the image
Here is the answer. I cannot disclose why I know this, but this is what you need to do.
Remove all images from your Watch App target.
Added images to an image asset file that is in your Watch App target.
Reference the images by the name in the asset file.
If you can see the images in the simulator and they are not in your Watch App target and they are in an asset file then they will work for the reviewer.
As of Xcode 6.3, iOS 8.3:
Leave off the ".png" part of the image name. It will look strange in the storyboard, showing a blue "?", instead of the image thumbnail, but will work on both the simulator and watch. Same goes for specifying PNGs for Context Menus and programmatically specifying animation.
If you're setting the images in your extension code, you should add all the images to the extension target too.
Verify the filenames are correct and the images are placed in the correct target's asset library.
WatchKit Images
It is recommended that you place image resource files in the bundle of your WatchKit app (not in your WatchKit extension’s bundle). Placing them in the WatchKit app bundle lets you use the setImageNamed: method of this class to specify the animated image. Setting them using that method offers better performance by eliminating the need to transfer the images from the user’s iPhone to the Apple Watch. The other methods for setting an image must wirelessly send the UIImage object or image data that you provide to Apple Watch.

Cannot connect a property to storyboard

I am building a master detail iPad application. Trying to connect a property declared in my view controller's.h file.
#property (weak, nonatomic) IBOutlet UILabel *aboutGame;
#property (weak, nonatomic) IBOutlet UITextField *gameDescription;
The file owner has been set as I am able to connect the *aboutGame property to a label on my storyboard. Trying to set the Text field to an element just does not seem to work. Am I missing something here?
The following shows up when attempting to connect the textfield. (Note the same is going wrong when trying to link a UIImageView also)
You have UITextField in definition and UITextView on Interface builder. So it is not showing you the option to connect.
Try like this:
#property (weak, nonatomic) IBOutlet UITextView *gameDescription;

xcode IBOutlet won't connect to codes

I am using xcode 4.3
I have a huge problem:
I started creating an application using storyboard for the ipad. At first i added my objects in interface builder, and then I dragged the blue line to the .h file and xcode made the connection and created a:
#property (strong, nonatomic) IBOutlet UIButton *button1;
with the filled up circle.
But after a few days, I tried to add a UIScrollView. I added the object to the storyboard, and dragged the line, but it would not connect and create a property. So I made first the codes,and tried to link, but same problem. So I deleated the scroll view and inserted again a button and lable. BUT NOW ANY OBJECT WON'T LINK TO THE CODES IN ANY WAY!!! WHY? To solve the problem I have to start again from the biginning!!
I create:
#property (strong, nonatomic) IBOutlet UIButton *button2;
drag the line: NO
drag to view controller: NO
did the opposite: NO
WHY???
You need to make the scene an instance of class ViewController instead of UIViewController, which is the default. You can change this in the identity inspector (third tab in the utilities)
If you're trying to drag the line to anything other than a button you're not going to have any success.
If you want to drag the line to a scrollview, you need to change the declaration to
#property (strong, nonatomic) IBOutlet UIScrollview *scrollView;
//^^^^^^^^^^^^ this type determines what it links to in interface-builder

How to convert a project based on a master detail controller template to a simple model view controller template?

I started to create a project from the master detail template and realize that my main controller should be a simple mvc. Is there any simple method to do the conversion beside recreate a project from scratch with a mvc template? What should be edited then?
The templates just set up your appDelegate with the proper elements. You could edit your appDelegate quickly, but unless you have a really compelling reason to edit the existing project it would likely be faster to just recreate the project.
With the master-detail template the appDelegate will have these properties (and code in the .m implementing them):
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) UINavigationController *navigationController;
#property (strong, nonatomic) UISplitViewController *splitViewController;
The standard template will have these (plus the implementation code):
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) ViewController *viewController;
The implementation file of the appDelegate will also be slightly different due to the NavigationController and SplitViewController in the master-detail. You can just change these files around and update your xib files, but again, it's probably just as fast to start a new project.

Resources