因为NStokenField不支持滚动条,我将它嵌入滚动视图中,但它不起作用...... 起初我使用NSTokenField的约束如下:
但似乎在输入大量标签时NTToken帧高度没有变化,而不是我试图动态增加它,这就是我所做的:
public override void ViewWillAppear ()
{
base.ViewWillAppear ();
this.View.Window.MakeKeyAndOrderFront (this);
TxtTagField.Changed += (o, e) => {
ResizeTokenField ();
};
}
void ResizeTokenField ()
{
//
if (!TxtTagField.Cell.Wraps) {
return;
}
CGRect frame = TxtTagField.Frame;
var width = frame.Size.Width;
var size = frame.Size;
size.Height = nfloat.MaxValue;
frame.Size = size;
nfloat height = TxtTagField.Cell.CellSizeForBounds (frame).Height;
if (height > 44) {
var fr = TxtTagField.Frame;
fr.Size = new CGSize (width, height + 23);
InvokeOnMainThread (() => {
TxtTagField.Frame = fr;
});
}
}
但仍然没有结果:(