Stanford's initial assignment not working - xcode

Stanford put out for free a series of videos and handouts for their iPhone programming course. I've played around with the first assignment, but all I get on the Simulator is a blank screen. Here's the recipe I followed; what am I missing?
In Xcode, create a new Window-Based iPhone application.
Open the project’s MainWindow.xib file with Interface Builder.
Add the following user interface elements to the view:
a text label
an image view
Set the following properties on the text label:
text value should be “Hello Stanford!” (or something suitably amusing)
text alignment should be centered
adjust the size to make the text large
Back in Xcode, add an image (.png or .jpg) to your project. You can use the Project > Add to Project... menu to select an image. Note: Be sure to check the “Copy items into desti- nation group’s folder (if needed)” checkbox.
Once your image is in the project, return to MainWindow.xib, select the image view and set the image for the image view that you dragged in previously using the Attributes Inspector.
Configure the image view’s “Mode” to be “Aspect Fit”
In Xcode, build and run your project in the simulator.
Been there, done that, but no t-shirt. Seems to me I'm missing connecting lines in the Interface Builder, but I see nothing in the recipe about that.

Since you didn't provide a link, I'll assume you're talking about this document.
Works for me on XCode 3.2.3/Snow Leopard 10.6.4. I created the project as iPhone-only, as opposed to Universal, but it shouldn't make a difference for your purposes.
Try again from scratch, or take a look at my project here.

Related

ToolbarItem icon set after the loss

my English level is limited, it may be difficult to read, please understand.
I use the NSSidebarTemplate icon in the ToolbarItem control of the project. But every time you open the Xcode, will be lost, there is no way to use NSSidebarTemplate. The missing results are shown in the picture. Open the project will have a pop-up box prompts, probably meaning
The document "Main.storyboard" had an internal inconsistency that was
found and repaired.
I have no way to use this NSSidebarTemplate, but most of the other icons do not have such a problem, such as NSActionTemplate is normal
It comes from a template project from Apple. The image name is NSSidebarTemplate. You can see it by digging into the storyboard or xib xml:
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSSidebarTemplate" imagePosition="overlaps" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="zzz-zzz-zzz">
There might have been a change in Xcode that made the image name displayed as 'Unknown' at some point, though internally it's still there.
This is also discussed here: The Sidebar Icon image name in OSX

Icon for Action Extension in iOS8

I have worked on extensions and it's all very interesting. For all type of extensions, icons work really well except for Action Extension where the icon is all white? Do you know how to create an icon for Action Extension?
In the Build Phases of your Extension Settings, just add Images.xcassets (or the icon file) to the Copy Bundle Resources.
PS: For Action Icon, any color data in the image itself is ignored. via Apple Docs
The alpha channel of the image is used as a mask to generate the final
image that is presented to the user. Any color data in the image
itself is ignored.
I had to manually add my icon assets catalog in the build settings. I described it here:
To get this to work with my existing Asset Catalog, I had to add the following to the extension's Build Settings:
The name of the set in my Assets Catalog is "ExtIcon". I had tried setting the CFBundleIcon and the NSExtensionServiceToolbarIconFile keys in the info.plist for the extension, but had no luck. This actually seems to make sense since it is the same way that icon sets are linked to the container app, not via info.plist, but via the Build Settings.

Button image not visible

I'm trying to create a Windows 8.1 store app, and I need to add a button to it.
The button should display an image.
I add the image to the assembly in Solution Exploreras Artwork/Pencil.png
I add the button to the UI
Using the property editor for the button, I select Foreground image.
The designer shows a list of available images from the assembly, I choose the image.
The designer shows the selected image (partially).
The button remains blank.
I tryied playing around with different content types (of the image), as Content, Embedded resource, Do not copy, Copy if newer.
The image is not visible either at design or run time.
I found tons of articles from 2005 to 2012 about this problem in WPF. Tryed to change the image source (although I think the designer should set it correctly):
Pencil.png
Artwork/Pencil.png
pack://siteoforigin:,,,/Pencil.png
pack://siteoforigin:,,,/Artwork/Pencil.png
pack://application:,,,/Pencil.png
pack://application:,,,/Artwork/Pencil.png
Any ideas?
To make the environment clear:
Visual Studio 2013 Update 2
Project type: Visual C#/Store Apps/Windows Apps/Blank App
Target: Windows 8.1
It seems that the correct combination (to display an image on a Windows 8 app button) is:
set it as backbround image (as opposed to foreground)
set the file to be "PRIResource" (as opposed to "Embedded resource")
use the designer to specify the image (which will generate a reference like this "Artwork/Pencil.png")
:-(
It works design-time, but it does not work runtime.
Here's one that works both design-time and runtime:
set it as backbround image (as opposed to foreground)
set the file to be "Content", "Copy if newer"
use the designer to specify the image (which will generate a reference like this "Artwork/Pencil.png")

How to get your custom content drawn in Interface Builder?

I watched the "What's New in Interface Builder" session video and tried to replicate the code that was showed but unfortunately when I assign a view to my custom class which has #IBDesignable I get 2 errors:
Main.storyboard: error: Live Views: Failed to update auto layout status: The bundle “swiftTest” couldn’t be loaded because its executable isn’t loadable.
Main.storyboard: error: Live Views: Failed to render instance of _TtC9swiftTest14ControllerView: The bundle “swiftTest” couldn’t be loaded because its executable isn’t loadable.
Later on in the video I saw that to have Live Views you have to make these steps:
1. Create framework
2. Create class
3. Mark as designable
How do I make the 1st step?
Thanks
As I understand it at the moment (prior to Xcode 6 Beta 3), #IBDesignable will only work from a view declared in a separate framework target.
However, I also struggled to add it because I had no "plus" button as described in various links (because the Hide Project & Target Lists arrow option was toggled off).
So, select your current project target, then just use the xcode menu options:
Editor > Add target...
Then select
Framework & Library > Cocoa Touch Framework etc.
By the way, to test #IBDesignable, this tutorial worked perfectly as a starting point:
http://www.weheartswift.com/make-awesome-ui-components-ios-8-using-swift-xcode-6/
One small but important thing to note in that tutorial (if you follow it onscreen instead of following on to its full github code listing) is that your view class must be prepended/decorated with #IBDesignable, e.g.
class CustomView : UIView {...}
should be
#IBDesignable class CustomView : UIView {...}
You should make new framework as a target for current project and add your live views in this framework. On General tab on main target you will see your framework in Embedded Binaries section.
I had a project with live views working and at one point I also had these error messages. This went away for me when closing XCode and restarting, fwiw.
It is working very well (and easily) for me with Swift in Xcode 6 Beta 5.
I've confirmed that with Xcode 6 Beta 5 I did not need to add any frameworks (for example, Cocoa Touch framework option under frameworks in the dialog that appears when adding a new project target). Nor did I need to add IBDesignable.h to the project. Both seem to be outdated requirements as per the the weheartswift.com write-up linked in the initial answer to the question.
All I needed to do was:
Prefix class definition of my custom Swift class source file
with keyword #IBDesignable
Prefix vars I wanted to show up in IB Attributes Inspector with #IBInspectable (IB recognizes several common variable types).
Then, after assigning my custom component's (UIControl subclass) name to IB's "Class" name file (under Identity Inspector tab, in right pane) replacing "UIView" -- e.g. the class name of the UIView placeholder object I originally dragged onto the IB VC's view -- upon selecting my custom component from the Content View component list in IB, I saw all my custom class' inspectable items show up in the IB Attributes Inspector!! Very cool.
Note: At first XCode would only allow me to prefix one variable with #IBInspectable. It showed errors on subsequent ones. Then, suddenly it seemed to work, and no more problems after that. Not sure if it was a typo or just took Xcode awhile to re-index my project and pre-compile or parse the code.
I code about #IBDesignable & #IBInspectable,
firstly, I got two errors like you,
then, I change the code I wrote,
you can checkout the code from my github
Good Luck.

Images showing up that shouldn't in iPad application

I have an iPad application which has many categorized images I need to switch between.
I store the categories in a database, along with the image prefix and number of images for that category. Using a random number in the range of 0-to-image_count_for_category, I get an image name like this:
[image_prefix][random_number].png => "SomeCategory3.jpg"
The images themselves are included in the project file structure and are not stored in the database.
All the image swapping is going fine. The problem lies in some of the image usage... I used to have an image "SomeCategory3.jpg", which was in the application, and has been displayed. Now, I replace the image named SomeCategory3.jpg, and the old image shows up ... Um ... how is that possible?
I have tried removing the app from the device, cleaning the project, re-building, and re-copying to the device for debug. Still, the old image comes up in that random rotation.
My app never copy the images anywhere. I simply reference them using the app folder with the image name appended.
I have verified that the old images are not in the folder or referenced by the project. I have viewed all the images in xcode to ensure the image displays properly.
Yet somehow ... the old image gets used in my random image swapping rotation.
It's driving me mad trying to figure out how the old image is there.
Any ideas?
Thanks!
Kevin
Xcode can't tell the image changed and did not overwrite the one in your app bundle's Resources folder. Right-click the image in your Xcode project and click "Touch" then rebuild. That or clean your target and rebuild.

Resources