I'd suggest:

float width = cell.ContentView.Bounds.Width - captionSize.Width - 10;
(add a bit of padding between them)

entry = CreateTextField (new RectangleF (cell.TextLabel.Bounds.Right +
10, yOffset, width, captionSize.Height));

Not sure it's Bounds there, might be Frame.

I suspect it's overlapping because the Label isn't at 0,0, it's at (at
a guess) 10,5, so you have to take that into account with your width
and starting position calculation.

Don't forget that you WANT to reuse the cells, the "take out the if
(entry = null)" but was a work around to see if it was a location
setting problem. Recreating it each time isn't a good idea. You might
want to do:

if (entry == null)
{
  //create it and set it up
  entry.Tag = 101;
} else {
  entry = Cell.ViewWithTag(101) as UITextEntry;
  //setup the size here
}

or do all the sizing in LayoutView


On Tue, Jan 31, 2012 at 06:54, MojoDK <[email protected]> wrote:
> Hi Nic,
>
> That helped a lot!
>
> Now I'm only facing one problem. I can't measure the Caption width
> correctly, so my textfield is overlapping the end of the caption...
>
> http://monotouch.2284126.n4.nabble.com/file/n4343662/iOS_Simulator_-_iPhone_-_iOS_5.0_(9A334)_4.png
>
> Here's my code so far...
> http://pastebin.com/qdPjBU6g
>
> I tried measuring like this:
> cell.TextLabel.Text = Caption;
> SizeF captionSize = new SizeF (0, 0);
> captionSize = cell.TextLabel.StringSize (Caption, UIFont.FromName
> (cell.TextLabel.Font.Name, UIFont.LabelFontSize));
> captionSize.Width += 10;
> float yOffset = (cell.ContentView.Bounds.Height - captionSize.Height) / 2 -
> 1;
> float width = cell.ContentView.Bounds.Width - captionSize.Width;
> entry = CreateTextField (new RectangleF (cell.ContentView.Bounds.Width -
> width, yOffset, width, captionSize.Height));
>
> But that doesn't work ... eventhough there should be a space of 10 between
> the caption and the textfield.
>
> Any idea?
>
> Thanks!
> Mojo
>
> --
> View this message in context: 
> http://monotouch.2284126.n4.nabble.com/MT-Dialog-right-aligned-EntryElement-tp4341288p4343662.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch



-- 
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to