コードを分析すると、次のロジック エラーが発生します。
メッセージ 'frame' の受信者は nil であり、ガベージになるタイプ 'CGRect' の値を返します。
これらの2行で:
CGRect rectFrame = purchaseCell.lblValue.frame;
CGRect rectFrameBG = purchaseCell.lblValueBG.frame;
コードはうまく機能しますが、これが何を言っているのか理解しようとしているだけです。私は何か間違ったことをしていますか?
編集:完全な方法は次のとおりです。
purchaseCell.lblHeader.font = [UIFont fontWithName:@"AvenirNextLTPro-Regular" size:16];
purchaseCell.lblHeader.text = curField.fieldName;
purchaseCell.lblValue.text = curField.fieldValue;
purchaseCell.lblValueBG.text = curField.fieldValue;
purchaseCell.lblValue.font = [UIFont fontWithName:@"AvenirNextLTPro-Regular" size:16];
purchaseCell.lblValue.backgroundColor = [UIColor clearColor];
purchaseCell.lblValueBG.textColor = [UIColor clearColor];
[purchaseCell.lblValueBG sizeToFit];
[purchaseCell.lblValue sizeToFit];
CGRect rectFrame = purchaseCell.lblValue.frame;
CGRect rectFrameBG = purchaseCell.lblValueBG.frame;
NSLog(@"RectFrame X: %.2f", rectFrame.origin.x);
purchaseCell.lblValue.frame = CGRectMake(rectFrame.origin.x-rectFrame.size.width,rectFrame.origin.y, rectFrame.size.width+14, rectFrame.size.height);
frameSizeWidth = rectFrame.size.width;
purchaseCell.lblValueBG.frame = CGRectMake(rectFrameBG.origin.x-rectFrameBG.size.width,rectFrameBG.origin.y, rectFrameBG.size.width+14, rectFrameBG.size.height);