In Xcode 4, I failed to find where to set UITableViewCell's Identifier, can anybody helps me?
Thank you very much.
In code:
myTableViewCell.reuseIdentifier = #"CustomIdentifier";
In the interface design document (right-click and view image to get a bigger picture):
Go to the leftmost tab here, the Project navigator.
Select the .xib file containing your cell design.
Select the UITableViewCell object within the .xib
Make sure the rightmost "View" is showing and then go to the 4th-from-left tab, the Attributes inspector.
The top box labelled "Identifier" is where you enter your identifier.
When you create a new UITableViewCell in an interface document, select it, show Utilities by pressing Cmd+Opt+0. Under the "Attributes" inspector the first object is your identifier.
You can use the attribute named 'tag', type of NSInteger
Related
So I've been using Xcode 7's new feature to reference storyboards within storyboards. To add clarity to my references, I want to add a comment of sorts that can explain exactly why I've split up my storyboards.
Does this feature exist? I know I can create some dummy views but I feel like this is lazy and a bit inefficient.
In you identity inspector there is a place you can write notes, that's basically your comment section.
Select your storyboard Object
Click show the identity inspector.
Then write your comment in the document note section.
This is a good way of commenting visually on a storyboard, but still isn't perfect and is still a dummy view. I find it is probably the cleanest way to do it right now.
Add a Storyboard Reference to your storyboard
Navigate to the Identity Inspector on the Storyboard Reference you added
Set the Label attribute to your desired comment
You can now move the your comment wherever you want inside the storyboard
You can place comments inside the source code of the storyboard. Since .storyboard files are XML-based, you can write standard XML comments in it:
<!-- This is a comment -->
To open a storyboard as source code, right-click on the file in the Project navigator (the first icon from the left on the right sidebar) and select Open As/Source Code:
To return to Interface Builder, select Open As/Interface Builder - Storyboard from the same contextual menu.
WARNING: Always place these comments after the first line of the file, since Xcode expects an XML declaration there.
this is a basic question I know but i'm a newbie so if you don't mind I will ask it anyway.
I'v created a custom UITableViewCell class, and dragged a label from the object inspector to it:
Now I know that I need to connect this label to the files owner or something like this right?
So what I though is to click on the label, go to the connections inspector and drag an outlet to the label:
What do I need to select from the selection box that came up...is that right? please correct me if i did something wrong..thanks ahead!
You have to create a variable UILabel in your cell.h then the name of this variable will appear in the list.
I am trying to change the identifier of my uitableviewcell in storyboards. The problem is that options pain doesn't have the option available anymore. See the image below:
As you can see the options are limited. How can I see the full range of options?
When I hover over the Table View Cell menu bar, there is an option to 'Show' which then allows me to set the identifier.
You minimized the area that allows you to edit the identifier and style etc. You need to click on the header called "Table View Cell", and it will expand the options for you. That's happened to me plenty of times. Hope that helps.
New to Xcode here -- Is there a way to get more detail out of Xcode when it runs into a compile time error? The only message I get when I try to build my application is "Interface Builder Storyboard Compilation Failed". I have no idea what file it's having a problem with.
Nothing additional turns up under the "Build" item in the Log Navigator either.
Thanks to wufoo I figured mine out.
I have a tableview that has five static cells. The cells have an assortment of UIImageViews, UITextFields, etc. I had created IBOutlets in the main UITableViewController .h file and connected directly to the static cells UITextfields in the storyboard. You can't do that.
Once I removed those connections it compiled fine for me.
It appears you have to connect UIWidgets (textfields, labels, imageviews, etc) in a statically created cell directly to IBOutlets in that cells .h file (NOT, as I did, to IBOutlets in the tableview .h file).
---- UPDATE ----
Ok, so my initial post was not entirely accurate. It appears you CAN connect IBOutlets from subclasses of UITableViewCell directly to the main UITableViewController .h file. You just have to make sure that you set the Table View Content field to "Static Cells". I missed that step.
Here is an image to illustrate:
Select your storyboard, in the detail pane on the left, ensure that your "Table View" is selected. In the pane on the right select your attributes inspector panel and change from "Dynamic Prototypes" to "Static Cells". Setup your static cells by dragging and dropping your components onto the storyboard, then if you want to link from your components directly to IBOutlet properties on your main ViewController .h file you can.
I discovered the issue I was having was that I set up static cells in storyboard, and then tried to recreate them again dynamically in the delegate method cellForRowAtIndexPath:. That does not work very well. If you use static cells you do not need to use any of the cell setup delegate methods.
Here is some excellent reading that also helped me out:
Apple TableView Programming Guide
For what it's worth, the problem seems to be related to two IBOutlet objects declared in my .m file. One was referencing a UISlider and the other a UILabel. I removed the references and then declared them as class variables instead. In viewDidLoad I hooked them up using [self.view viewWithTag:TAG_FROM_STORYBOARD_WIDGET]. Looks like the same solution as mentioned by
f.perdition in the link above.
For me, it was two identical storyboards in the project that lead to this error popping up frequently.
I created a storyboard X, added a view controller Y in it. Then I refactored a view controller Z to storyboard X. Xcode asked if I want to replace the existing storyboard X and I selected Yes.
Its only after a few hrs I noticed that there are two references for the storyboard in file / project navigator (left pane). Removed one of the referneces and the issue hasn't shown up after that.
In my use case I have added a new target that runs the build script that is using xcodebuild. I was receiving the same failures but the reason was Mac Catalyst support being YES by default in Build Settings. (My main target doesn't support Mac Catalyst.) Changing those to NO in Builds Settings fixed the issue for me.
One of the UITableViewCells in my table contains a UIView which is like a 5-star ratings. However, the view cannot be selected.
The tutorial I'm basing it on is the following from Ray Wenderlich:
http://www.raywenderlich.com/1768/how-to-make-a-custom-uiview-a-5-star-rating-view
Any ideas?
Is User Interaction Enabled checked for the rating view in your storyboard file? In the Utilities right-hand sidebar of the storyboard editor, under the "Attributes" inspector's "View" section, you should find the "User Interaction Enabled" checkbox. (A similar checkbox also appears in the "Identity" inspector, see here for details.)