我是Objective-C的新手。我想在警報視圖中顯示當前的日期和時間。UIAlertView帶時間戳
- (IBAction)postButtonPressed:(UIButton *)sender {
NSString *formatString = [NSDateFormatter dateFormatFromTemplate:@"MMM d, yyyy h:mm" options:0 locale:[NSLocale currentLocale]];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:formatString];
NSString *todayString = [dateFormatter stringFromDate:[NSDate date]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message Posted" message:@"Your Message is posted on: @todayString" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}
什麼是你的問題? – 2013-02-22 05:43:58