UISwitch in static UITableViewCell generates error - uitableview

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.

Related

UIButton backgroundColor doesn't change on first UITableViewCell

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.

UICollectionview with IBOutlet-UIButtons not working

I have a two-days-brain-breaking-question to all of you:
I integrated a menu in my application by using a UICollectionView (one line, horizontal scrolling, fixed number of 9 items). Every cell has an own tag and uses an own prototype cell with own identifier. During the cellForItemAtIndexPath I assign a prototype cell to every cell (the prototype cell contains the specific UIButton in the storyboard). If you click a cell (respective the UIButton) a popover should open (this is working quite well, because the popover is anchored to the collection view not to the cell - otherwise Xcode will give an error, because of an outlet bind to repeating content.). Now to the questions:
Dependently from the chosen value in the popover, the name (titleLable.text) of the button should change. I think, an IBOutlet is needed, but not usable, because of the possible (but not happened) multiple (re)use of the cell.
Some other action in the APP could happened randomly, that changes the label of the button. Therefore an IBOutlet is needed too, I think.
I tried to give the prototypes a specific tag, but this (in my opinion) could not be used, because I cannot assign the tags to an UIButton, during loading, because not all of the cells are visible and therefore not reachable in viedDidAppear...
Any help is appreciated. This is a new try for an old problem and the collectionView till yesterday looked quite promising. Any ideas to help? Thanks a lot. I canĀ“t give code, because 90% of the work are done in IB.
you can use NSNotificationCenter to send message from your UIPopoverController to a UICollectionViewCell.
Send and receive messages through NSNotificationCenter in Objective-C?
Just subclass UICollectionViewCell to MyCollectionViewCell and use your subclass in your UICollectionView.
At the -(void)initWithFrame:(CGRect)frame method of MyCollectionViewCell you should subscribe as an observer to NSNotificationCenter, and unsubscribe in dealloc.
Than all your cells may receive notification and react to it.
This is not an optimal way of receiving callbacks, but maybe the simplest.

Static UITableViewCell blank - Swift, iOS 8

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.

UILabel doesn't clear, draws over previous contents

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 ...

Incorrect UISwitch appearance in UITableViewCell

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!

Resources