How do I control the direction in which my UILabel Expands? - objective-c

I have several Buttons each with three UILabels alongside them, half of these buttons two labels to the left as shown below. Each label has a number within it between 1 and 3 digits and will expand (using the UIView method 'sizeToFit') to fit this number. However when the labels are on the left the view overlaps the button when it expands. How can I fix this?

Related

How to display an image and two labels in a three column UITableView?

I need to display multiple columns in my UITableView. The first column, will be an Image, and the next two will be a label. How can I do that programmatically?
For Example:
TableView
MyImage Text#1 Text#2
Image Another Sample
You try with custom cell and then put a 3 views over there or taken directly UIImageView and Two UILabel. It is More easy.

OS X Autolayout - Arranging views around main view

I want to arrange eight views around one main central view so that as the main view is programatically moved or resized, the surrounding views keep their same positions. This link shows the layout.
http://homepage.ntlworld.com/bernie.w/Autolayout.png http://homepage.ntlworld.com/bernie.w/Autolayout.png.
Note:
Views 2 & 7 are vertically centred on the main view.
Views 4 & 5 are horizontally centred on the main view.
I'm new to autolayout, so any pointers how to achieve the above appreciated.
Just add horizontal spacing constraints between 4 and Main view then 5 and Main view. Then add vertical spacing constraints between 7 and Main view then 2 and Main view. You should then be able to do vertical spacing 'greater than or equal to' from 1 to 4 then do horizontal spacing 'greater than or equal to' from 1 to 2. Repeat that 'greater than or equal to' process for horizontal spacing and vertical spacing for the 1-3-5, 5-8-7, and 4-6-7 views and you should get the result that you want. Let me know if you have any questions about that.

Controlling XAML grid structire using VisualStateManager

I am writing a WinRT app and need to change its layout in a snapped view. In a regular view details are displayed in grid of a following structure:
MainGrid: contains 2 rows, 2 columns (let's call them M11, M12, M21, M22)
DetailGrid: occupies rightmost column and upper row of MainGrid, contains 1 row, 2 columns of equal, so the layout looks like this:
M12 contains D1 and D2 layered horizontally
In a snapped view I want DetailGrid to be redefined so it has a single column and 2 rows:
M12 contains D1 and D2 layered vertically
If I didn't care about column width, I could use StackPanel instead of Grid to display details and simply change StackPanel orientation in a snapped mode from Horizontal to Vertical. But D1 and D2 must use all available space in a standard mode and have equal size, therefore I control them via Grid ColumnDefinition. But grid definition is not something that is easily controlled using VisualStateManager.
What do you think would be the best way to manage such layout?
Thanks in advance
Grid definitions are hard to control but I've found changing Grid.RowSpan or Grid.RowColumn span on the controls within the grid should be able to do what you need in snap view

AQGridView: How to adjust UIGridViewCell margin

I'm trying to implement the AQGridView in my iPad app. Please see my below image -- sorry for the strong colors, but I think it would help you understand my problem.
Each cell (the blue box) has a margin left and right (yellow color), i.e. 8 pixels. This means that the first yellow coloum has a width of 8px, the second 16px, third 16px, and the last 8px. That's maybe fine in some situations, but I would like the yellow columns to have the same width. In my example the total width of the columns are 48 (8+16+16+8) so instead I would like each column to have a width of 12 (48/4). How can I change the AQGridView to do this?
I've tried to change the frame and bounce the AQGridView, but that did not do anything.
AQGridView actually takes the container view's coordinates and creates a strictly-defined grid from that. So when you have a 768px-wide grid view, and items which are a little under 1/3 of that in width, then it will create a rigid grid in which to place these items. By default your AQGridViewCell views will be centred within each grid square (although you can call -setResizesCellWidthToFit:YES to change that); you can adjust that positioning by implementing -gridView:adjustCellFrame:withinGridCellFrame: in your AQGridViewDelegate implementation.
In your case, every single cell has a margin of 8px on its left and right sides. On the outer edges this is seen alone, but in between pairs it appears doubled to 16px (8px from each cell).
What you want, then, is for each cell to have a 6px margin, and for the grid itself to have another 6px of margin space to the left & right of all cells. There's an API for this:
#property (nonatomic, assign) CGFloat leftContentInset;
#property (nonatomic, assign) CGFloat rightContentInset;
What you should be able to do is set myGridView.leftContentInset = 6.0; and myGridView.rightContentInset = 6.0;. The grid view will then lay out cells with a content width of 756px instead of 768px, which should give you a 6px margin around each cell. Combine that with the 6px left & right content insets and you'll have a clean 12px visible margin between every cell and the outer edges of the grid view.
Side note: the content inset properties were actually created to assist with laying out a certain number of cells per row. For instance, 1024 doesn't divide by 5, so it could end up with some fairly small cells being quite spread out since the layout grid would only contain 4 items in width. However, by adding left & right content insets of 2px each, the view would use a width of 1020 to calculate its layout grid, resulting in 5 cells per row. This is, in fact, exactly what we do in the Kobo iPad app when rotated to landscape mode; without that change, our portrait-mode 4 items per row just got spread out & it looked a little too sparse.
I managed to gain more control on the horizontal and vertical spacing by using the portraitGridCellSizeForGridView method and returning a slightly large CGRect compared to the one I used to initialise the cell in the gridView:cellForItemAtIndex: method.
I hope this helps.

set scroll last UItableview cell

when I scroll position end of UItableview the last UItableview row seems half. how can I show the last row fully and how can I detect scroll to last row?
I don't know what you mean by "seems half". I suppose that means only half of the cell is shown? Make sure the frame of the whole table view is visible first.
If you want a cell to appear within the bounds of the table view, use
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:? section:?]
atScrollPosition:UITableViewScrollPositionBottom animated:YES];
I think there is something (like a tabBar) at the bottom of your screen and it is overlapping the UITableView .. am I right, am I right?!
Just make the frame of the UITableView 48 pixels shorter. That's the average size of a tabBar..
Or perhaps you have not taken in account that the bar at the top (the status bar) also counts, which is about 15 pixels high. In that case, take 15 pixels of the height of your UITableView's frame.