Auto layout vertical constraint sometimes has no effect within UITableView - ios

I have a UITableView. Each row contains a UIView that contains two UILabels. The vertical spacing between the two UIlabels is specified with an auto layout constraint. It looks like this:
+-------------------+
| +----------+ |
| | +------+ | |
| | | text | | |
| | +------+ | |
| | | ROW |
| | +------+ | |
| | | text | | |
| | +------+ | |
| +----------+ |
+-------------------+
This usually works but sometimes the cell is rendered without space between the UILabels. When it doesn't work no error is printed. It seems non deterministic. I.e. if I create two cells with the exact same contents one might be rendered with the correct vertical spacing and the other without the spacing.
If you have any advice on how to figure out the problem please let me know.
Right now the table uses estimated row heights which seems a little flaky.
tableView.estimatedRowHeight = 100;
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}

I run into the same problem occasionally.
When the result of UITableViewAutomaticDimension is near to the value of estimatedRowHeight,ten to one this problem will appear.
So I set the value of estimatedRowHeight to an impossible low value,such as 2,to work around,and it works fine.

Related

Stretchable white space in a cell

In one of my Google Sheets I have the following formula:
="Azarenka: "&countif(B$9:B,"Azarenka")
that is rendered like
| Azarenka: 4 |
but I'd prefer to have the equivalent of an \hfill in TeX
| Azarenka: 4 |
Is this possible?
Probably not possible without some scripts reading the column width in pixels.
Why not have a column for the names, and another column with the scores? Then get rid of gridlines (View>Gridlines>uncheck). Then add some borders in the appropriate places and color to get the right effect?

How to SUM filtered columns for each row?

Google Sheets question.
I have the following sheet which can grow by adding both rows and columns. The first cell of added columns can be either red or blue, randomly:
MonthYear | red | blue | blue | red
Jan/2017 | 100 | 200 | 10 | 20
Feb/2017 | 800 | 900 | 50 | 60
The result I need should hold the sum for each color:
MonthYear | red | blue
Jan/2017 | 120 | 210
Feb/2017 | 860 | 950
How can I do this with formulas that update the result automatically when adding new rows/columns in the data sheet?
Thanks a bunch!
Single formula solution, paste the formula into another sheet:
={FILTER(Sheet1!A:A,Sheet1!A:A<>""),{TRANSPOSE(UNIQUE(TRANSPOSE(FILTER(Sheet1!B1:1,Sheet1!B1:1<>""))));MMULT(ARRAYFORMULA(OFFSET(Sheet1!B2,,,COUNTA(Sheet1!A2:A),COUNTA(Sheet1!B1:1))*1),ArrayFormula(--(TRANSPOSE(UNIQUE(TRANSPOSE(FILTER(Sheet1!B1:1,Sheet1!B1:1<>""))))=TRANSPOSE(FILTER(Sheet1!B1:1,Sheet1!B1:1<>"")))))}}
I've made a Sample sheet with solution and explanation.
I set up an example sheet that produces this output:
https://docs.google.com/spreadsheets/d/1xex8ptlabXsclb5fJFO5pG78_EQPAJ65xxpNHDhshoU/edit?usp=sharing
The formulae used are:
cell A1: =ArrayFormula(Sheet1!A:A)
cell B1: =TRANSPOSE(UNIQUE(TRANSPOSE(Sheet1!B1:1)))
cell B2: =SUM(QUERY(TRANSPOSE(QUERY({Sheet1!$A$2:$A,FILTER(Sheet1!$A$2:$Z,Sheet1!$1:$1=B$1)},"where Col1= date '"&TEXT($A2,"yyyy-mm-dd")&"'",0)),,1))
The B2 formula is then copied to the rest of the B2:C3 range

How to hardcode arbitrary Tick text labels on y axis in highcharts

I'm using the highcharts heatmap to display fixed interval data, sometimes with 24, 48 or 96 values in a day.
On the y axis I don't want to display each time depending on the interval, this would clutter the y axis.
How can I hardcode arbitrary labels along the extent of the y axis. I want 24:00 at the top, 00:00 at the bottom, and 06:00, 12:00, 18:00 evenly spaced out in between?
24:00 |
......... |
......... |
18:00 |
......... |
......... |
12:00 |
......... |
......... |
06:00 |
......... |
......... |
00:00 |
I don't think what I've asked for is possible, so I ended up computing a suitable tickInterval elsewhere to pass into the chart

Highlight cell if value is present in any cell in another column

I want to highlight the cell in column A if it is repeated anywhere in column B. For example:
A | B
pack_1 | unrelated
pack_2 | unrelated
pack_3 | pack_1
pack_4 | pack_1
pack_5 | pack_3
pack_6 | pack_3
pack_7 | unrelated
pack_8 | pack_2
In the example, pack_1, pack_2 and pack_3 should be highlighted because they are mentioned in column B.
How can I do such a thing?
Please select ColumnA, Format, Conditional formatting..., Custom formula is:
=match(A1,B:B,0)>0
with formatting of choice.
Do conditional formatting on each cell with the formula:
=EQ(VLOOKUP(A1, B:B, 1, FALSE), A1)
And format the cell to a different color if it matches.
I shared an example here (this link will ask you to make a copy in your own Google Drive account):
https://docs.google.com/spreadsheets/d/1IovLko1cF2guKnIalCyE0uSbCvMDYLgL0BZHt35znXI/copy
You would add conditional formatting to A1 and then copy to rest of the cells in the column.
Set the conditional formatting to custom formula and make the formula:
=COUNTIF($B$1:$B$8,A1)
And set your color.
It will highlight the cells in the A column if they exist in the B column.
(Keep in mind I Am assuming your range is B1:B8)
Select both columns
click Conditional Formatting
click Highlight Cells Rules
click Duplicate Values (the defaults should be OK)
Duplicates are now highlighted in red:

Core Plot: Format time labels on x-axis based on range of data

So I'm plotting on an XY graph time along the x-axis and what I'd really like is for the axis labels to format themselves based on the range. (EG a small range would give hours, larger range could be days, years etc)
So something like 8 AM | 9 AM | .... | 11 PM
then NOV | 2 NOV | 3 NOV | ... | 30 NOV |
then 2001 | 2002 | 2003 | ..... | 2020|
etc. Can CorePlot do this for me? I know http://d3js.org/ can do it for my web friends.
Use a plot space delegate to monitor changes to the plot space. -plotSpace:didChangePlotRangeForCoordinate: is a good method for this purpose. After each change, check the current value of the plot range for the changed coordinate (x or y) and update the axis labels appropriately. When the plot range crosses a transition threshold, update the labelFormatter and other axis properties. Which ones need updates will depend on the labeling policy in use and the desired appearance.

Resources