当我分析我的项目时,我得到奇怪的错误函数调用arument是一个未初始化的值,我搜索了很多但没有得到任何解决方案,我使用此代码。谢谢你的努力
在最后一行得到问题
rect = CGRectMake(ceilf(rect.origin.x), ceilf(rect.origin.y), ceilf(rect.size.width), ceilf(rect.size.height));
代码
CGRect rect;
if (self.segmentWidthStyle == HMSegmentedControlSegmentWidthStyleFixed)
{
rect = CGRectMake((self.segmentWidth * idx) + (self.segmentWidth - stringWidth) / 2, y, stringWidth, stringHeight);
rectDiv = CGRectMake((self.segmentWidth * idx) - (self.verticalDividerWidth / 2), self.selectionIndicatorHeight * 2, self.verticalDividerWidth, self.frame.size.height - (self.selectionIndicatorHeight * 4));
fullRect = CGRectMake(self.segmentWidth * idx, 0, self.segmentWidth, oldRect.size.height);
}
else if (self.segmentWidthStyle == HMSegmentedControlSegmentWidthStyleDynamic)
{
// When we are drawing dynamic widths, we need to loop the widths array to calculate the xOffset
CGFloat xOffset = 0;
NSInteger i = 0;
for (NSNumber *width in self.segmentWidthsArray)
{
if (idx == i)
break;
xOffset = xOffset + [width floatValue];
i++;
}
CGFloat widthForIndex = [[self.segmentWidthsArray objectAtIndex:idx] floatValue];
rect = CGRectMake(xOffset, y, widthForIndex, stringHeight);
fullRect = CGRectMake(self.segmentWidth * idx, 0, widthForIndex, oldRect.size.height);
rectDiv = CGRectMake(xOffset - (self.verticalDividerWidth / 2), self.selectionIndicatorHeight * 2, self.verticalDividerWidth, self.frame.size.height - (self.selectionIndicatorHeight * 4));
}
// Fix rect position/size to avoid blurry labels
rect = CGRectMake(ceilf(rect.origin.x), ceilf(rect.origin.y), ceilf(rect.size.width), ceilf(rect.size.height));
答案 0 :(得分:0)
您正在将rect传递给ceilf,而如果两个ifs都失败,则可能无法初始化。将第一行更改为CGRect rect = CGRectZero;
将修复警告,但我不确定这是您可能需要的行为。