auto resize label in custom cell during delete - objective-c

Im making on an ios app and currently working to get cell deletion from a tableview working. I have the ios swipe to delete working with the default red button appearing in from the right to delete the cell. all working wonderfully. But the problem im having is that i cant get the 2 uilabels that are within the custom cell to autoresize over when the red button moves in. so the red button is currently covering up one of the labels . i have been trying afew things with no luck so far.
primaryLabel.contentMode = UIViewContentModeLeft;
primaryLabel.bounds = primaryLabel.frame; //incase auto resize was using bounds instead of frame
cell.autoresizesSubviews = YES;
primaryLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;//tried various options in here
Im hoping to get a solution to this through code rather then with IB on this particuliar problem. So any help would be appreciated
as requested screenshot. the D is start of second label that isnt autosizing with the rest

If you are adding the labels via code, make sure you are adding them to the cell's contentView and not directly as subviews of the cell. The content view is resized when the cell enters editing mode, the main cell is not.

Related

tvOS tableView scroll smooth from cell to cell

In my tvOS-app I use a tableView with custom cells. If the cell is higher than the TV-screen it will show the "center-part" of the cell (top and bottom are not visible) and scrolling up or down will center the cell above or below. Is it possible and if, how, to change the "jumping" from cell to cell to a smooth scrolling like in iOS?
You should limit your cells to use a fixed height for a few lines of text and show focus. When a user selects one of the cells you can then expand / zoom / transition to show the whole text is a specific scrollable text view. This interface maintains the users understanding of content, lists and block text.
Just found the solution. Knowing what to search could be an advantage ;-)
Adding this simple line gives me the handling like in iOS:
self.tableView.panGestureRecognizer.allowedTouchTypes = #[#(UITouchTypeIndirect)];

Background color in cells in NSTableView is 1 pixel off

I am making an OSX app, and for part of it, I am using NSTableView to simulate a "timeline", by putting in a really thin column and then setting the background color. It's fine, except for whatever reason the cell seems to be 1 pixel off whenever the background color changes. Anyone got any ideas? I don't have the reputation to post an image so here's the link: http://imgur.com/PrLdjIV
Thanks for reading this!
An NSTableCellView will not necessarily fill a row from edge to edge. Likewise, an NSTextField inside such a cell view will not necessarily fill it from edge to edge.
Implement -tableView:didAddRowView:forRow: in your table view delegate and set the row view's backgroundColor.

UIButton in UICollectionViewCell resets its label text to what is set using storyboards from the runtime text being set on every click

I am working on an app having a collection view with Collection view cells having 4 buttons to invoke different actions.Each links to a different IBAction. I have read multiple threads across the board and had decided to use storyboards rather than go at it programmatically since 'this could be the way forward'. So while setting up the buttons, I had set default label text to Button 1, Button 2 etc. In the code, while giving cell for index path, I am changing the button text to something programmatically. When the application is run the cells render fine with dequeueing, and the text being set programmatically is set correctly. However, when I click any of the buttons, the action is called, but the label text of the button resets to what was set using storyboards.
I have tried everything to retain the text label copy to what it should be. But to no avail. When I again dequeue the cell by scrolling across the collection view and the view gets redrawn, the button again gets the correct text.
Can anyone please shed some light on why the button text for a button placed in a collection cell will reset its text and will not allow it to be set unless the view is redrawn.. Also any ideas on how to fix this.
Thanks a ton
deej nailed it --
I had the same problem but was doing something stupid:
self.btnProperty.titleLabel.text = #"button title";
rather than:
[self.btnProperty setTitle:#"button title" forState:UIControlStateNormal];
Use the latter.

UICollectionView does not reveal all cells in Simulator

I am not very experienced with UICollectionView and Auto-Layout.
I have a very basic UICollectionView inside a root view. The root view seems to have a Navigation Item.
I created a custom cell which is really a square in proper size to allow 2 such cells per row using the FlowLayout.
There are 8 such cells in the view - it is basically a grid. I have absolutely no constraints on the view.
The collection view occupies the entire size of the root view according to the IB and in the editor, the first cell is placed right under the navigation item which is perfect.
However, when I ran the app in the simulator and scrolled the collectionview all the way to the button, I see only a partial fragment of both cells in the last row. I can see I have scrolled all the way down...
Obviously there seems to be some sort of overflow...but I would have thought uicollectionview would automatically handle the overflow and make all the cells visible?
When I set number of items in IB I can see that the cells in the last row are only partially visible.
Seems like content size of the collection view is not right - that's my guess..
What do I need to do to adjust things in IB so that all of my cells are visible...I do not want to hardcode any values in the code...
Thanks.
Solved. It turns out simulator does not show the entire collection view...the same shows fine on the device... What a headache...

Apples keyboard appears then scroll code sample does not work correctly

I have a UITableView with a navigation bar on top. I have several text fields in the cells and if i click in the cell at the bottom the keyboard hides the text field. So I googled and found this link: http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html#//apple_ref/doc/uid/TP40009542-CH5-SW7
I used exactly that code and run my app again. Now it scrolls up (about the height of the keyboard) instead of scrolling down. Also it scrolls in every cell, even the cells at the top which will not get hided by the keyboard. Does anyone have a solution for this? I tried to log out some coordinates inside the keyWasShown: method but it's very complex for me to figure it out.
So I used trial and error and finally found out, that I have to add two superview properties behind activeField:
activeField.superview.superview.frame.origin
Do this behind every activeField in the method keyboardWasShown: and it will work. Ah and I added 70 pixels, because the view didn't scroll exactly where I wanted it to, maybe it is because of the navigation bar I use, I don't know:
activeField.superview.superview.frame.origin.y - kbSize.height + 70