I created a sectioned UITableView and added a custom cell that includes a UISwitch. All this is done using the storyboard. However, when running the App (Simulator/device), the UISwitch does not look as expected (c.f. attached screenshot).
Any ideas on why this happened are highly appreciated (XCode 4.5.2, iOS 6.0.1). Note: creating a new UIStoryboard does not solve the problem.
I just got the answer to my question: I created a category on UIImageView that sets custom layer properties (e.g. shadowRadius). Setting a breakpoint on the corresponding UIImageView method, it revealed that the UISwitch called it.
I did not get to this point earlier, as I only had a single UIImageView before (and this one was supposed to have custom properties). Thanks for all your comments!
Related
I'm currently developing an application in Swift and, when i run my application on an iPhone 6 (which runs iOS 12.4.6), occurs a strange problem.
I have a UITableView with many of UITableViewCell inside it and, these cells, contain a UIButton which backgroundColor needs to be updated by a specific condition. The problem is that, only the first cell, doesn't load correctly the color, on the contrary it's loaded only after the cell is reused by the UITableView.
I've had a similar problem before (on the same device) inside a UIViewController and I barely resolved it by shifting the code used to control the backgroundColor from the viewDidLoad method to the viewWillLayoutSubviews method.
In my opinion it's something related with the storyboard overriding some values, I've already tried to set the condition on awakeFromNib inside the UITableViewCell but nothing changes, and I can't actually figure out what else may be causing this problem.
Problem solved, I've actually tried to put the code inside the DispatchQueue.main.async as suggested and it worked fine without any problems.
I am trying to implement some static cells in a UITableView using Xcode 6 beta 2 and Swift. I have successfully implemented dynamic cells.
When the user clicks on one of the dynamic cells there is a push segue to a new UITableViewController for a UITableView with static cells.
I have set this all up in Xcode and the segue works but when I drag a UILabel onto one of the static cells it just doesn't show up at run time. A few things that might help narrow down whats going on:
The data source methods are not being implemented in the UITableViewController
If I set the background of one of the static cells to a particular color, that shows up at run time
Any advice much appreciated.
Thanks in advance
I "fixed" the issue creating a new storyboard...
On a clean project it was working, maybe it's a bug?
I believe this is the answer here:
https://stackoverflow.com/a/24708004/3827274
TLDR: it's an Xcode bug with changing the view to 'compact' width which seems to only affect alignment/positioning. Click on your UILabel inside the cell and go to the inspector all the way to the bottom and play with the 'Installed' or note if the default one is disabled.
I would like to create a UIViewController with various options, each can be enabled/disabled with a UISwitch.
I'm using Xcode 5 and iOS 7 deployment target.
The UITableView contains static cells. The interface is created in a storyboard.
When I'm adding a UISwitch to a cell (to it's contentView) I get this error:
Exception while running ibtool: *** setObjectForKey: object cannot be nil (key: objectID)
Isn't it possible to add a UISwitch to a static UITableViewCell?
When removing the UISwitch the error disappears.
I have the exact problem today and I couldn't figure out what is causing my problem because I have added too many items on my view controller. Now I know it is the UISwitch.
But I have resolved the problem, nonetheless.
I disabled the "Accessibility" option and the build was successful.
But How come the "Accessibility" option becomes an issue of Object Id remains unclear.
For static table cells one has use to a UITableViewController. Static cells are not supported by UITableView.
Another answering this point: https://stackoverflow.com/a/9428324/42756
A bit late but to the game, but...
If you define a User Defined Runtime Attribute to an AutoLayout constraint that is a Placeholder (i.e. removed at build time), you get this error.
I have a UILabel whose text I change from time to time. When I change the text, however, it doesn't erase the old text -- it re-draws on top of the old text and accumulates.
The UILabel is inside a UITableViewCell.
Has anyone encountered this problem? How do you fix it?
This happen when u customize UITableViewCell by [cell addSubView:UILabel] method.
So let me explain it in some detail:
We use [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; method to get cell to use.
This method can one of two thing:
Return new object of UITableViewCell.
OR
Return old object of UITableViewCell which is not right now on screen. (To improve performance)
If it is fresh than no problem but if it is not than the controls which we have added by
[view addSubView:view] method are already there and we add it again on same position like stack of same controls.
We can solve it by two way:
code in such a way that add [UIView addSubView:UIView] only if it is fresh cell.
(I suggest this) Use subclass of UITableViewCell also call Custom UITableViewCell.
You will find many tutorial on this let me give u some:
Creating a Custom UITableViewCell
How To Design A Custom UITableViewCell From Scratch
If you are using storyboard than it is very easy:
Creating Table Views with Storyboards
Using Xcode Storyboards to Build Dynamic TableViews with Prototype Table View Cells
All the best...
people! I`ve come over similar problem and was trying to create new question, but I decided to write inside this topic for not to make new one. So here is the my case:
I am trying to develop localised app, in which English words set to label normally by wordLabel.text = #"SomeNewWord"; but in case of Russian - new words are written above old ones. this case does not appear while I have some breakpoints to stop activity of the game. When there are no stopping factors the problem shows up. This happens only on iPhone with Russian language selected as default. on iPad everything goes well. I also tried to wordLabel.text to nil before assigning new word to the ULLabel. No reaction at all. The problem is present on both simulator and iPhone 4s for now.
my UILabel is made from storyboard and has #property (nonatomic, weak) IBOutlet UILabel *wordLabel;
UPDATE
after finding this post useful one at the bottom I`ve solved my problem. The answer was to UNCHECK Opaque in interface builder ...
I've been following this Apple Doc to add a custom UITableViewCell that I layed out in an .xib to my project. One problem with the doc is that it seems like it was written for an older version of Xcode.
I'm able to load my UITableViewController that the custom cells are on, but the cells are all blank. My custom cell contains several UILabels, and has a non-default background color. The table that appears when I run has the default white background and no labels. If I change the UITableView's View -> Background on my storyboard, the color of the cells' background changes, but the labels still don't appear.
Of interest is the fact that the data is still in my table's cells. The UITableViewController is itself called as a popover from another controller. When I select one of the cells, the strings from the various label.texts are supposed to be loaded into their own labels on the popover's delegate, and that code works fine (except when I try to include a UINavigationBar in my popover, but that's probably another issue entirely).
I'm still pretty new to iOS developement, so if there's anything I'm leaving out or being unclear about let me know.
Edit - cleaned up code, now is completely different question than when I originally posted, but is still on the same topic. Should I have deleted the old question and posted this as a new question all together, or is it alright that I just edited it?
I'm still not entirely sure what was wrong with what I was doing before, but I managed to get what I wanted. I originally dropped a UITableViewController onto my storyboard set up a popover segue (also on the storyboard) and tried to display the popover with performSegueWithIdentifier. Instead, I now create the popover completely in my code (which I found a nice tutorial for here on SO, by goggling "show popover programmaticly"), without having anything for it on my storyboard. That seems to be the most documented and stable way to show a popover. Once I displayed it that way, my custom cells showed up exactly like I wanted.