I have parsed CSV file data and populating in a UITableView. I have five labels and a button in the cell. The labels are showing data appropriately but the button is not visible. I have dragged the button onto the storyboard. I have created a outlet variable also. But still the button is not visible. What could be the reason ?
Even when i change the position of my label now and run the app it doesn't change.
Does this have something to do with core-data ? Because i have saved my csv data as core-data
Hit the runtime UI debugger key when in the considering VC is showing. The button should be above the console panel the second last one. Right now am not in my mac so cant post a screenshot.
Hit the button and observe that your button is being drawn beneath some view or your button is being drawn at all.
Plz confirm and comment
I suggest you to apply auto layout constraints for button and labels. I think it will work.
REASON: your label is over your button. If you don't use auto layout label width get width of tableView (least the initial position x) and background default to white AUTO when your app running.
Change in code the label background to 'clear' and button will appear or search the button in the cell and use method 'bringSubviewToFront:'.
BEST SOLUTION? Use auto layout constraints.
Related
I am new to swift and iOS development. I have created a scroll view with table view cells and image views inside cells. Each Image view has a button with same constraints. I have a fixed button in the same screen (irrespective of scroll view) and I am not sure how to achieve the click for it since every time I click on it, the background button is being clicked. I saw some solutions about disabling and enabling the buttons but in this case, I will not be sure which button will be in the background since it is a scroll view. Any help on how to solve this will be appreciated
Since I don't see your code, I can't tell you the exact fix but I assume that the question is how to determine the button's position in the parent view hierarchy. Every UIView has a method called bringSubviewToFront(view:) so if this was the case, then, you can use this method to bring your button to the front.
I am loading different components in the tableview. Each component is having different types of data such as video, image, quick reply and other component.
I am able to load all the data and added to the table view and table view height is adjusted based on the data response.
Now my requirement would be one specific component is displayed at the bottom of the screen always. How do I change the Y position of the particular component?
The problem which I am facing now, not able to change the position of that component.
You can use another UIView fixed at the bottom of the screen below your tableView. You can put that component in that UIView. This way it will be fixed at the bottom.
Another option is using a TableViewController instead of a TableView. That way you can have static cells. You can set the last cell at the bottom however you like. It never changes.
I know how to accomplish this in something like sprite kit but with just a normal ViewController I'm a little lost - right now I have my button and my UITextfield set up on my xib file. Right now, when the button is clicked my textfield goes from hidden to not, which is great.
Problem is I need to have my button slide up (as in animate up) to "reveal" the text field when clicked. As in the textfield would be underneath the button. When another button is clicked, I want the button to slide back down to its original position. I don't know how to implement these animations.
Here is an image of what I need:
So the blue button would trigger the move up when clicked. Then if another button is pressed the blue button moves back to original position over textfield.
How can I accomplish this?
Here's an option you can try if you aren't displaying these in a UITableView:
Setup your .xib with all of the possible views in an 'expanded' state. Give your views that will be revealed a height constraint (in addition to the others needed to layout the view properly), and then create an outlet for those height constraints in your view controller. Additionally, store a reference to what you want the expanded height of the view to be in your view controller.
In viewDidLoad of your view controller you will set those height constraints' constant values to 0. This will cause these views to effectively disappear, and your other views should fill in the gaps they leave behind based on their constraints.
When one of your buttons is pressed, you'll update which views should be visible by setting their height constraint to 0 if you want them hidden, or to the value you saved earlier if you want them shown. After the height has been updated, call
UIView.animateWithDuration(howLongTheAnimationLasts) {
self.view.layoutIfNeeded()
}
which should animate the change in height values.
Alternatively, you could try putting your options in a UITableView and altering their height using tableView:heightForRowAtIndexPath: and reloading the cells when their heights should change.
I have a Scroll View with a View (content view) inside of it. I've added two buttons to test. The Scroll View scrolls fine but the buttons within the content view are not clickable. I've seen plenty of posts saying this issue happens when they programmatically add UIButtons to the View, but I am not doing this. Here is my exact process:
Drag the Scroll View onto the main view. Add 4 constraints
Drag the Content View onto the Scroll View. Add 4 constraints.
Add 2 Buttons (one high and one low to test scrolling) to the Content View.
This is all I am doing, no code at this point. Is there anything else I have to do to allow the buttons to be clicked? Here is a screenshot of my xib:
Update:
When hooking the button up to a simple IBAction and logging a message, it turns out it IS being pushed and working properly. However, when the button is pushed, the button isn't changing colors like it should (its "pressed" state is not appearing). Any ideas why?
First make the button to custom type
Select button from storyboard then on right attributed inspector change its "state config" to whatever you need like Highlighted, selected, Disabled and default and choose the colour for each state.
Now you can see the colour change on that button.
A UIScrollView first needs to know whether or not you are going to scroll before letting the touch pass to its child views. If you want the child views to get the touch immediately, set the UIScrollView's delaysContentTouches to NO.
For a custom widget, I want to display a list of items in the modal slide-up way that you get from setting a view as the inputView on a widget (that is, it replaces the keyboard for that widget).
I can do this with no issue, but when I set a UITableView as the inputView, it seems to think it is taller than it is. I can scroll all the way past the bottom so that the last item is not even displayed. When there are fewer items than fill the area it adds blank rows way past the bottom of the visible area as well.
Is there something about the inputView area that causes stuff to not know how tall its container is? Is there a workaround?
So, instead of using a UITableViewController, we wrapped it (in the storyboard) in a normal UIViewController with a table view in it, and that seems to be working fine.