UIDatePicker
文本在彈出的子視圖中添加時截斷viewController
。UIDatePickerView文本添加爲子視圖時關閉
代碼是象下面這樣:
datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(10, self.view.frame.size.height-120, self.view.frame.size.width-20, 120)];
datePicker.timeZone = [NSTimeZone localTimeZone];
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
// self.datePicker.minimumDate = [NSDate date];
datePicker.backgroundColor=[UIColor grayColor];
[self.view addSubview:datePicker];
檢查圖像:
編輯:
Printing description of self->datePicker:
<UIDatePicker:0x7fd0b971c0a0; frame =(0 280; 300 120);layer =<CALayer: 0x7fd0bf30a2e0>>
(lldb) po self.view
<UIView: 0x7fd0bf331f40; frame = (0 0; 300 400); clipsToBounds = YES; autoresize = LM+RM+TM+BM; tag = 23942; layer = <CALayer: 0x7fd0bbf81730>>
你在哪裏寫代碼?在didLoad? – Dalvik
最有可能你會得到datePicker的錯誤幀。 'self.view.frame.size.width'給你額外的寬度 – Dalvik
用某種方法寫這段代碼,這是從一些按鈕單擊調用的,並且我記錄了寬度,這與上面的工具欄具有相同的寬度,如datepicker @ RahulMishra –