I am trying to make a tab system in my app such that when a UIButton is tapped, the view switches and a line moves from the other tab button to under the button that was just pressed, and the same for the other tab button. I am doing this by creating a UIView for the green line and two UIButton's for the tab buttons. Both the Buttons are hooked up to IBActions which remove a constraint that ties it's center.x to the old tab button's center.x and add a constraint that binds it to the new tab's button's center.x. However, the button needs to start aligned to the first tab, and when I try to add that constraint programmatically in viewDidLoad, it crashes with "View Hierarchy not prepared for constraint". I cannot add this initial constraint in IB because I need some way to remove it when the next button is pressed.
I will be happy to provide code or more details if needed.
Thank you
Related
when I'm unwinding a segue by clicking on a button with a cross image which is 1/4th inside a UIView and 3/4th outside the UIView now when I press on button the part which is inside the UIView then unwind segue works but if I click outside of UIView then it does not works.
As you can see from above image if I click inside the blue line then other view controller opens and If I click outside blue line of cross button the unwinding of segue does't work, why?
You can View the Video
<img src="https://i.imgflip.com/24bh0k.gif" title="made at imgflip.com"/>
The cross button seems to be inside the card view rather than superview. Put the button inside superview, over the card view but outside the card view.
Do something like this
take the button up on the view and set its constraints properly . May be your problem will resolved.
(See Sketch)
How would I implement this behaviour with an already visible toolbar? Also, the little information I found on opening a UIPicker modal are all based on using a UITextField which is not what I'm aiming for.
What I'm looking for is a button on the toolbar opening the picker modal with the toolbar attached to it. Button1 on the sketch is simply to select a value the user is most likely to pick (Something like "Go to todays date"), and done should hide the modal and bring the toolbar back to it's original state of being attached to the bottom of the screen.
Ideally, I'd like this toolbar with the picker functionality to be avaiable on multiple views.
You could add constraints to your storyboard, connect them as outlets to your code and then disable and enable the appropriate ones whenever needed.
One constraint setup would be:
add a constraint that pins the top of the picker to the bottom of the view
add another constraint pinning the bottom of the picker to the bottom of the view
-> If you enable 1 and disable 2, the picker is hidden
-> If you enable 2 and disable 1, the picker is visible
That change in constraints is animateable which will result in a smooth UI change.
I currently have a view with a navigation controller and two menu bar items, the left one causes a slide out panel to appear using SWReveal. What I want to do is add a navigation controller to the slide out panel, but make it so the right button doesn't get cut off by the upper view.
I want a button just to the left of where the hamburger button on the upper view is. I'd like to do this in Swift, if there's no way to do it in the storyboard.
I found the solution after looking at this post. Just go into SWRevealViewController.m, scroll down to the _initDefaultProperties block, and change the value of _rearViewRevealOverdraw from 60.0f to 0.0f.
The Apple guide "Adding Auto Layout Constraints with the Pin and Align Tools" states:
To create a constraint related to another item that is not the nearest neighbor, click the black down arrow in the text field and choose another nearby item from the pop-up menu.
https://developer.apple.com/library/ios/recipes/xcode_help-IB_auto_layout/chapters/pin-constraints.html
My Storyboard has a UIView containing a UITextView and a UIButton.
I'll note that these objects are not visible "on the storyboard" in a view. They're only visible in the left sidebar due to the limitations of Interface Builder. So I cannot place the button "to the right" on the storyboard by default (if that's what's causing this problem).
I need to add a constraint between the Text View and the Button. The Text View should be on the Left, followed by the Button, with a Margin between.
However when I add a constraint, the two objects used are the Text View and the parent UIView. Not the Button.
The "nearest neighbor" of the Text View should be the button.
I'm also unable to select the button as the second item from the menu, as the guide advised. Only the parent UIView is available.
Why is the Button object not available in that menu?
How should I add a constraint between the Text View and the Button?
The views only show up that make sense for the direction you chose. So, if one view is above another, and you choose the left or right constraint, the other view does't show up. If you choose the top constraint, it should.
Another way to do this is to control-drag from the text view to the button in the scene list, and choose the constraint you want from the popup window. After you create the constraint, you can edit it to change the value if you need to.
I have a UINavigationViewController, and from InterfaceBuilder I added a ToolBar clicking on Attributes Inspector / Navigation Controller / Shows Toolbar
My RootViewController shows a ToolBar with a single button now, but for some reason I cannot modify it. Clicking on the toolbar selects the underlying RootViewController, I can add buttons by drag-dropping them, but I cannot select existing buttons (so no modifying or renaming them is possible).
How can I modify the UINavigationViewController's ToolBar items from InterfaceBuilder?
Thank you.
In Interface Builder, if you click on the toolbar in your .xib, it will probably not select your toolbar button but the entire toolbar. Try looking up your toolbar in the outline view left of the design view and there click in the button to select it.