0
我是記分牌應用程序,我不需要在按鈕單擊時添加UItextfield和標籤。我不斷收到這些方法的錯誤。有什麼建議麼?CGFloat中的錯誤消息
錯誤消息: 「分配爲 '的UIView *' 從不兼容的類型的 '雙'」
self.yOffset = 60.0;
錯誤消息: 「分配從不兼容的類型 'CGFloat的'(亦稱 '浮動')「的UIView * 」」
frame.origin.y = self.yOffset;
錯誤消息: 「無效的操作數的二進制表達式( '的UIView *' 和 'CGFloat的'(亦稱 '浮動'))」
self.yOffset += frame.size.height;
下面是代碼:
-(void)addPlayerTapped:(id)sender {
NSLog(@"Adding Player");
self.yOffset = 60.0;
UIViewController *llVC = [[DetailViewController alloc] init];
llVC.view.alpha = 0.0;
[self.playersArray addObject:llVC];
[self.view addSubview:llVC.view];
[self repositionFields];
}
-(void)repositionFields {
// Reposition each view in the array
for (DetailViewController *llVC in self.playersArray) {
CGRect frame = llVC.view.frame;
frame.origin.x = 15;
frame.origin.y = self.yOffset;
llVC.view.frame = frame;
self.yOffset += frame.size.height;
}
// Add some animations to make it look nice
[UIView animateWithDuration:0.3 animations:^{
CGRect frame = self.addPlayerButton.frame;
frame.origin.y = self.yOffset;
self.addPlayerButton.frame = frame;
} completion:^(BOOL finished) {
DetailViewController *llVC = [self.playersArray lastObject];
llVC.view.alpha = 1.0;
}];
}
你如何聲明'yOffset'? – Macondo2Seattle
@property(assign,nonatomic)CGFloat * yOffset; – user3088011
這應該是'CGFloat yOffset',而不是'CGFloat * yOffset' - 你不希望它是一個指針。 – Chuck