Resize UIView to hide the portion under the "cut line" - objective-c

I am designing an editable UITableViewCell*. In the normal state, my cell should look like the portion of this image above the red line.
When users click [Edit...], the controls letting the user change the settings will show up, and the text of the [Edit...] button will become [Done]. Clicking [Done] will hide the portion below the red line, and change the text on the button back to [Edit...].
I am trying to achieve this effect by changing the height of the row in the delegate. When the cell is in edit mode, it's returning the full height; when the cell is not in edit mode, the height of the upper portion from the red line on is returned. Unfortunately, when I do that, the edit controls "slide up", obscuring the rest of the cell. I am fixing this by making these controls invisible in the edit mode, but I think there should be a better solution.
Are there settings that I could apply to the controls in order to let me cut off the bottom, clipping the content below the red line?
* I am using Interface Builder to design my cell, in case it matters.

In your xib - just turn on the top strut
This is working for me. To make it smoothly expand and contract you'll need to use the trick of an empty beginUpdates/endUpdates call
[tableView beginUpdates];
[tableView endUpdates];

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)];

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.

NSPopUpButton in NSToolbar such annoying

Problem solved!:
Just check the "Unified Title And Toolbar" option of the NSWindow and the 1pixel-down problem goes away!
To change the toolbar height just select the Toolbar Item - Custom View and change size in the Size inspector.
==============================
If you know Xcode 5s layout than you should recognise this:
I want to build it for my own. So I dragged a Toolbar in the Window and added a NSPopUpButton. Then I changed the PopUp Button Cell Style to Radio and turned off the Arrows. So far so good.
The first thing I noticed is that the Toolbars has different heights. Does anybody know how to change this behaviour (without subclassing NSToolbar)?
The second and more annoying thing I noticed is that if I choose an Item from the PopUp Button the Image for the NSMenuItem move 1 pixel down.
EDIT: Xcode NSMenuItems don't move 1pixel down
Any suggestions about that thing?
NSToolbar, sadly, can’t really be subclassed. It’s a poorly-written class that tries to be very “magic,” so it’s not even a subclass of NSView—you can’t control how it draws at all, it creates a private view.
You can set its “sizeMode” but I assume you’ve already done that and found that the number of pixels high isn’t what you want.
The easiest thing to do is just leave space for your widgets at the top of your window (above the document content) and have autolayout position your buttons for you. (I haven’t been able to use a real NSToolbar in years because of its limitations.)
As for the popUp menu being mis-aligned with the button: where the menu draws is basically hard-coded, so if you use a button style that NSPopUpButton doesn't expect then the menu will be offset some.
If you’ve already tried just unchecking the “draws border” flag on a default-style NSPopUpButton (one fresh off the palette), There are two solutions for to try: One is to keep trying different buttonStyles that look correct to your eye until you find one that’s not offset. Two is to leave the buttonStyle do the default for NSPopUpButtons but subclass the buttonCell and have it not draw the border (but still leave room for it).

Remove or prevent the active widget highlight

In the above example image, how do I go about preventing the blue highlight you can see on the top and right side of the NSOutlineView control?
That's called the "Focus Ring". You should be able to stop your view from drawing it either through IB:
Or in code, using setFocusRingType::
[myView setFocusRingType:NSFocusRingTypeNone];

iOS table view having text fields scrolling issue

I have a UITableView which is composed of custom cells. There are 21 cells containing text fields.
When I try to scroll and edit the cells at the bottom of the UITableView, I can't manage to get my cells properly positioned above the keyboard.
Also i created a custom cell class separately for my cells. So keyboard delegates are available on that class only.
I have seen many answers talking about changing view sizes,etc... but none of them has worked nicely so far.
Could anybody clarify the "right" way to do this with a concrete code example?
There are three approaches to this problem all of which tie into the keyboard did / will show notification....
When the keyboard appears, you move the whole view (including tableview) up to ensure the selected textfield is shown on screen, you can calculate this by getting the keyboard height (from the notification) and the textfield position.
You can resize the tableview so that it is only as big as the portion of the screen not covered by the keyboard, again get the height from the notification.
You can set the content inset for the tableview (for the bottom value) to the height of the keyboard.
If you need to, when resizing or repositioning the tableview, you may need to set it to scroll the content to the rect of the text field to ensure it is in view...
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;