2
我要計算在Xcode此操作:文本字段日期選擇器計算
A * B *(天)= R
天=多少天是從過去的日期選擇器到今天。
今天是iPhone的日期設置。例如:
5 * 5 * 10
10 =昨天到今天之間的天數。
這是我的情況:
我^ h @interface ViewController中:UIViewController中
@property (strong, nonatomic) IBOutlet UITextField *a;
@property (strong, nonatomic) IBOutlet UITextField *b;
@property (strong, nonatomic) IBOutlet UILabel *r;
@property (strong, nonatomic) IBOutlet UIButton *result;
@property (strong, nonatomic) IBOutlet UIDatePicker *data;
@end
我們M
- (IBAction)calculate:(id)sender {
NSDate *past = _data.date ;
NSDate *now =[NSString stringWithFormat:@"%@",nil];
**float z = HOW MANY DAYS BETWEEN PICKER AND TODAY;** //this is a example
float a = ([a.text floatValue]);
float b = a*([b.text floatValue]);
float r= a*b*(z.text float);
_result.text = [[NSString alloc]initWithFormat:@"%2.f",b];
}
我知道,這是錯誤的方法....你能幫我?
好的。我有一個崩潰的問題。 –
粘貼你崩潰日誌並更新你的問題。 – sunkehappy
這次崩潰是故事板中的一個文本框 –