简体   繁体   中英

IOS 8 Interface builder UITableViewCell alignment

I am working on IOS app which got a UITabeView. I needed custom UITableViewCell, so i created .xib file to design it and linked it to my custom class. But I want a button to be aligned right and I cannot achieve it. The screenshot below shows my problem:

在此处输入图片说明

I am using autolayout. On the left side I have my .xib opened where I have a button. In the middle there is a simulator which show only a part of a button. Moreover, If a change orientation, absolute button position doesn't change (it becomes fully visible). On the right side you can see how I set constraints. Obviously, I did it in a wrong way, but I've tried everything and nothing helped. Different constraints, values, toggled autolayout - no effect. How do I set up constraints so that my button is aligned right (on both orientations)?

PS I am using Swift.

you have to link your button to the view which contains it, you can press Ctrl and drag the mouse from your button to the view which contains it, Xcode will show a menu with the available constraints:

在此处输入图片说明

You have to select the constraints you need for setting up the position of the button, in your case it will be leading space to container, and in addition you should select width and height constraints. For selecting those constraints you can press this button on the bottom of the screen:

在此处输入图片说明

and in the following menu select the width and heigth constraints:

在此处输入图片说明

Hope it helps!

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