简体   繁体   中英

UITableView Auto Height With Constraint problems Xamarin.iOS

I need to resize my UITableView with the height of his contentSize for this i made this:

private void ajustHeightOfTableView()
{
            nfloat height = tableViewCores.ContentSize.Height;
            nfloat maxHeight = tableViewCores.Superview.Frame.Size.Height - tableViewCores.Frame.Y;



            if (height > maxHeight)
                height = maxHeight;

            UIView.Animate(0.25, new Action (() => {
                this.tableViewAjustHeight.Constant = height;

                this.contentView.SetNeedsUpdateConstraints();
            }));
}

and

public override void ViewDidAppear (bool animated)
{
            base.ViewDidAppear (animated);
            ajustHeightOfTableView();
}

i have a IBOutlet with de Height Constraint of my UITableView... so i resize the tableview calling after reloadData() my function ajustHeightOfTableView...

The problem is: Below my UITableView i have another UIView with buttons and textfields WHEN i resized my tableView my another View does not work! she does not respond for the user interaction... i thing that my problem is that after the resize the view is not in the correct position.

i have another constraint with the Vertical Spacing between the UITableView and UIView like this: IMAGE 1

this constraint is to put my view in the correct space another my uitableview resize...

here my UITableView Constraint Height: IMAGE2

someone please know what am i doing wrong here?

I don't know if you can adjust the height and width separately, but I know of a method to scale the webpage to your view in both directions. This is done using the ScalesPageToFit .

UIWebView webView = new UIWebView (new RectangleF (0, 0, cellWidth, cellHeight));
webView.ScalesPageToFit = true;
webView.ScrollView.MinimumZoomScale = 1f; 
webView.ScrollView.MaximumZoomScale = 5f; 
webView.LoadRequest (new NSUrlRequest(new NSUrl(URL)));

Adjusting the Frame of the UIWebView won't work.

I hope this short information helps. Good luck!

Love and regards, Björn

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM