In xib table is having 1 rows
Dynamically as the app progresses in table from code there are 3 rows.
In table view I have button in cell on whole click I need to show one pop up view and set its frame according to cell frame
On the click I set frame of that pop up view
As soon as the pop up view's frame is set the view is seen as it is seen in xib
that is now instead of 3 rows there is only 1 row as in xib
These all happens when I set auto layout to true
If I set auto layout false there is no problem
I am not writing code as there is no code except I set frame with CGRECT
got it
in viewDidLoad I wrote
self.tblTemp.translatesAutoresizingMaskIntoConstraints = YES;
so now my table does not change frame.
In the scenario above I used autolayout in the view as I used the constraints for other controls, but I did not want to use for these particular table.
I did not use any constraints for table view, as I needed to change its frame dynamically.
so I put the above line
Previously table was automatically changing the frame to the one set in xib, on changing any particular frame(I need to show or hide pop up view on some cell button click, so I just set frame there)
I think here apple is translating my auto resizing constraints to auto layout ones. I am not still not sure how it is working. I read some where in apple guidelines about translatesAutoresizingMaskIntoConstraints, as actually by default it is YES.
If anyone finds useful
Related
i am using UItable view to show data. i have UIbutton in each cell on right side.when i select edit mode in table my UIButton displays outside from table.please tell me what should i do.
krishan
Use either autoresizingMask in code or the Size Inspector in IB to change the behavior to what you want, depending on how you created your button (code or IB). You can tell it to keep the left margin at a constant size, or change the width, or whatever you decide looks best.
I am making an iPhone App.
I have used table view in some View Controller.
In iPhone it is scrolling Ok.
I have converted the app to the iPad and autoresized the table view via IB and changed the size of CELL.
It is not showing me the last cell and giving me a jerky feel so I could not select it.
I don not know where I am going wrong?
Actually It is a problem of resizing autoresizing.
In my case
Table view is showing the correct result now.
You can see below tabe view I have used Image view, so by autoresizing property (IB) some part of the table hides below the Imageview because of extra stretching.
Otherwise table view is working perfectly well.s
I have tableview that scroll vertically. My question is when first this view is loaded, horizontal scrollbar appears at the bottom of tableview and disappears. It only happens when the view loads at the first time. I wonder why this is happening.
I'd hazard a guess that you accidentally checked the “Horizontal Scrollers” box in the table's properties in Interface Builder. To turn them back off again, either find that (under the “Scroll View” section of the inspector) and uncheck it, or just set the table view's showsHorizontalScrollIndicator property to NO in your controller's -viewDidLoad.
I have a UITableView as a subview in a ScrollView with other widgets around like a button. I'd like to put the button always at the end of the ScrollView and I'd like to have the UITableView to show dynamically more section. How and where shall I determine the Table size, correctly set it and visualize it?
From Interface Builder it seems that I can only set static size to the TableView (which of course limits the number of sections visible) and stick the button position to the bottom whether a rotation happens.
If you have only few simple controls after the table then I'd suggest putting them to the table itself and get rid of the unhealthy (in my opinion) combination of table view inside scroll view.
You might add the button you are talking about to the table's footer.
It may be done in the Interface Builder (drag-n-drop the button to the bottom of the table view) or in the code ([tableView setTableFooterView:myButton];).
If your button should be smaller that table's width then put it inside UIView and locate as you need.
You can also add table header in a similar way...
I have a UIView (created in IB) with a grouped UITableView as a subview. Below this table view is a UIButton. The XIB containing the view will be loaded by a few different viewcontrollers, and so the contents of the table view can vary between one and four cells.
Here's what I want to achieve: when the view loads, the height of the tableview (tableView.frame.size.height) should be adjusted depending on the number of cells, and the button should be placed just beneath the table view.
Can this be done? Could it somehow be done if the view is created programmatically?
Thanks in advance
Edit: Pxl's suggestion was just what I was looking for. A while later, the need arose to have more than just a button below the table view - this was accomplished by creating a separate view containing everything I needed, and implementing the tableView:viewForFooterInSection: and tableView:heightForFooterInSection: functions.
A note for those of you trying to do the same thing: the tableview has to be programmatically created if you want different heights for the footers, or footers for only some of the sections. This is because the footer height set in IB will override the one returned from the tableView:heightForFooterInSection: function.
if there are only a handful of rows, may i suggest that you create a special UITableViewCell that contains just a button?
then make that button cell the bottom row of the last group all the time. make the group so that it will be unlabeled and appear as if the button is sitting at the bottom of your tableview. this way you won't have to muck around with recalculating the tableview's frame and redrawing it.
if the tableview will scroll due to there being many rows, then you'd be calculating the height of the tableview up to a set max (at which point the tableview will need to scroll to show more rows).
once you've determined the height of the tableview you'll need to display your rows, make a frame of the appropriate size, set the tableview's frame to it, position the button just under the tableview, and then redraw the view.
the layout and positioning in this case will need to be done programmatically.
UITableview is a subclass of UIView, so you can change its frame to suit your needs just like a UIView, and UITableView will manage drawing itself to whatever frame you give it.
Just use the methods UITableViewDataSource and UITableViewDelegate provides you.
height = [self tableView:numberOfRowsInSection]*[self tableView:heightForRowAtIndexPath:] + A_CONSTANT_FOR_HEADER_AND_FOOTER_HEIGHT
I agree with pxl that adding a cell with the button in it may be the easiest way to accomplish what you want.
Whether or not you do that, the table view's sizeToFit method should resize the view to (just) fit its contents. If that doesn't work, you can use numberOfSections and rectForSection: to build a loop that determines the height of the table's contents, and reset its frame manually. (And then position the button underneath.)