im using NSTableView which needs to be updated with dynamic height
`NSAnimationContext.runAnimationGroup { (context) in
context.duration = 5
tableView.reloadIndex(tableView.selectedRow)
tableView.noteHeightOfRows(withIndexesChanged: [tableView.selectedRow])
}`
this is the code i used to animate... first if i try to animate by increasing one cell height the whole table view height increases gradually along with the animation... but again if i selected another cell..... the old selected cell should minimize the height and then increase the height of newly selected cell.... but what happens is... the table view automatically increases the size before cell completely loads and it looks weird (image 1)
in the image provided you can see how it looks (image2) but i want like this image to increase the height along with cell height hope some one helps me in understanding this... im a newbie so please help
Related
I am designing a chat app in which I am using the UITableViewAutomaticDimension property of table view when I am setting the label lines to 6 then all cells height is according to the text which label contains but when I increase the number of lines for label then some cells have extra height. Even when scrolling it then cell height again changed.You can check the image so that you can understand it easily thanks.
You need to give label constraints from top and bottom, rather than center vertically.
Give vertical content hugging priority
I have tried to search online for resize the UITableView(not UITableView cell) so that when I click the button, the tableview will minimise while the contrast of two button get closer.
TableView does provide ".hidden" function to hide itself, but it will leave a big blank space between those 2 buttons in User Interface.
So I plan to minimise the height of tableview while hidden it, but I only can get help to resize "UITableView Cell" and not "UITableView" itself.
Does there have anyway to resize TableView or adjust the UI contrast programatically?
If you views are frame based, you can simply set the TableView as hidden, and move the second button up by setting second button's origin.y like:
origin.y -= TableView.bounds.size.height
If you are using auto layout, simply change TableView's height constraint to 0 and change second button's top layout the same way as frame.
A more simpler way if you are using auto layout is, make the second button's top to TableView's bottom, so when you set the TableView's height constraint to 0, the second button will automatically move up.
Remember, when you are using auto layout, you change the constraints like how you change the frames. They are just different concepts, but internally, auto layout engine will translate the constraints into frame values.
Get the Constraint Of TableView Height from Storyboard.
#IBOutlet weak var tableView_Height: NSLayoutConstraint!
After that set the value of this table view constraint to 0
tableView_Height.constant = 0.0
apply following steps
1) take tableHeight constraint outlet
2) in numberOfRowsInSection.
if rowcount is equal to zero then set tableviewHeight constant to zero before return the rowcount.
3)if you want to set tableheight according its row count then set tableviewheight constant equal to ((totalrowcellheight)+fixsomespace)* in numberOfRowsInSection method. and aply some limit like if (height>300) then put it static height = 300
This may sound a newbie question, however I'm new to iOS dev.
I've got a UITableView on my iPad app. TableView has obly three rows, is there a way to tell UITableView to view rows vertically centered, i.e. to not from the top to down.
Figure out the sum of the heights of all 3 rows, call it MyTotalHeight.
float MyTotalHeight = heightOfRow0 + heightOfRow1 + heightOfRow2;
Set your
tableView.frame = CGRectMake(start_X, start_Y, tableWidth, MyTotalHeight);
If you want the contents of each row/cell to be centered vertically within the cell, this will depend greatly on what is in the cell. You will need to calculate the height of the content and then center that content vertically within the cell by adjusting it's frame.
You may want to try the UiTableView.sectionHeaderHeight property. Play with the number until the cells are centered vertically. If your using a plain table view, I don't know how well this will work for you.
--John
I'm trying to figure out where to properly set tableView.rowHeight. Currently I have it in my ViewDidLoad method, but as I am using images it seems to be scaling the images up from the default.
E.g. my cell images are 55px squared. But if I set [self.tableView.rowHeight = 55.0]; in ViewDidLoad, they look a bit blurry.
You have to make space for the table view separator line (that is 1px), so if your image height is 55px, your table row height needs to be 56px.
Setup: I have a scrollview with a label, uiimage, and a tableview (grouped) nested within. The label, uiimage, and tableveiw are populated by a webservice. The last section in the grouped table view contains text that will never be the same and could be as long as 5 characters to 250+. Also, this view is pushed from a basic tableview (so it has a navigation bar. If that matters at all).
Expected: The tableview should extend in height depending on the length of the content received from the web service. Then set the scrollview height to accommodate the height of the tableview
Problem: I'm not quite sure how to approach the issue. I really only know how to change the height to fixed values, which will not work properly in many scenarios.
The width and height of the cell are ignored; the cell cell is re-sized according to the value you return from -tableView:heightForRowAtIndexPath: or (failing that) tableView.rowHeight. It might appear as if the cell is big enough if the label in the cell is sized to be big enough, because the label is allowed to be bigger than (and render outside) the cell.
One way is to override -tableView:heightForRowAtIndexPath: to return the correct height. This isn't really the intended use of UITableView (it's primarily designed for lots of rows of a single height, dynamically generated from a list of content).
Another way is to set tableView.tableFooterView = myCustomFooter instead. This is probably the easiest way. Size it correctly before performing the assignment (the height matters; the table view will set the width for you anyway). Also make sure that the autoresizing flags are not set, or the size will appear to randomly change when the table view changes size (e.g. on autorotation).
I'd just focus on the variable height element, figure out the height that fits the text there. To figure out the height that a string will take when rendered use a snippet like this:
CGFloat MY_TABLECELL_WIDTH = 320;
CGFloat MY_MAX_HEIGHT = 10000;
UIFont *MY_FONT = nil; // load the correct font here.
CGSize maxSize = CGSizeMake(MY_TABLECELL_WIDTH,MY_MAX_HEIGHT);
CGSize textSize = [serverString sizeWithFont:MY_FONT
constrainedToSize:maxSize
lineBreakMode:UILineBreakModeWordWrap];