2
我無法定義常量。定義常量
這是我如何把它定義爲:
const float tableOffset = 200;
這裏是我嘗試使用它(見盡頭):
[self.voteTbl setFrame:CGRectMake(0,200,self.view.frame.size.width, self.view.frame.size.height - bottomBar.frame.size.height - tableOffset)];
但是,這並不工作,實際上設置正確的身高。此代碼工作:
[self.voteTbl setFrame:CGRectMake(0,200,self.view.frame.size.width, self.view.frame.size.height - bottomBar.frame.size.height - 200)];
我試過切換到int沒有運氣。編譯器不給出警告或錯誤。
我不確定哪一個做了它,但它工作。你介意給出一個解釋'f'和CGFloat的答案嗎?謝謝! –
我將我的評論轉移到了答案上,如果您想讓我詳細解釋發生了什麼,我可能也會這樣做。 –