我试图从标签或文本字段中的uipicker显示选定时区的日期和时间我没有得到任何方法来解决此问题,所以请任何人帮助我提前致谢。如何从uipicker在Xcode中获取选定时区的日期和时间
SelectedTimeZone = [Weight objectAtIndex:[pickerView selectedRowInComponent:0]]; NSString * selectedzone = SelectedTimeZone;
NSCalendar *gregorian=[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setTimeZone:[NSTimeZone timeZoneWithName:selectedzone]];
NSDateComponents *timeZoneComps=[[NSDateComponents alloc] init];
NSDate *date=[gregorian dateFromComponents:timeZoneComps];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterFullStyle];
[formatter setDateFormat:@"dd-MM-yyyy HH:mm:ss "];
NSString *todaysDate= [formatter stringFromDate:[NSDate date]];
zone.text = todaysDate; I know this is not proper way but i'm new to xcode
见此*你的努力将是非常有益的一些*代码。 – dasblinkenlight