2016-11-27 7 views
0

こんにちは私のコードに問題があります。
裁判官は、最初にいくつかの誤りを見つけようとしないでください。 Imは "非互換型ポインタ型 'NSDictionary * _Nullable'型のパラメータに 'UIFount *'を送信します"互換性のないポインタの種類xcode 8

ここにコードがあります。すべてのヘルプは、それはあなたがこの警告を得ている理由は、この

NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"YourFontName" size:YourFontSize]}; 

などの辞書を作成し、その後、これを渡します、

// Entirely cover the parent view 
UIView *parent = self.superview; 
if (parent) { 
    self.frame = parent.bounds; 
} 
CGRect bounds = self.bounds; 

// Determine the total widt and height needed 
CGFloat maxWidth = bounds.size.width - 4 * margin; 
CGSize totalSize = CGSizeZero; 

CGRect indicatorF = indicator.bounds; 
indicatorF.size.width = MIN(indicatorF.size.width, maxWidth); 
totalSize.width = MAX(totalSize.width, indicatorF.size.width); 
totalSize.height += indicatorF.size.height; 

//**Issue is HERE** 
CGSize labelSize = [label.text sizeWithAttributes: label.font]; 
labelSize.width = MIN(labelSize.width, maxWidth); 
totalSize.width = MAX(totalSize.width, labelSize.width); 
totalSize.height += labelSize.height; 
if (labelSize.height > 0.f && indicatorF.size.height > 0.f) { 
    totalSize.height += kPadding; 
} 

CGFloat remainingHeight = bounds.size.height - totalSize.height - kPadding - 4 * margin; 
CGSize maxSize = CGSizeMake(maxWidth, remainingHeight); 
CGSize detailsLabelSize = [detailsLabel.text sizeWithAttributes: detailsLabel.font 
          constrainedToSize:maxSize lineBreakMode:detailsLabel.lineBreakMode]; 
totalSize.width = MAX(totalSize.width, detailsLabelSize.width); 
totalSize.height += detailsLabelSize.height; 
if (detailsLabelSize.height > 0.f && (indicatorF.size.height > 0.f || labelSize.height > 0.f)) { 
    totalSize.height += kPadding; 
} 

totalSize.width += 2 * margin; 
totalSize.height += 2 * margin; 

答えて

1

sizeWithAttributeNSDictionaryを期待し、あなたがそれでUIFontを渡している...感謝されます属性辞書

CGSize labelSize = [label.text sizeWithAttributes: attributes]; 
関連する問題