结果仍然是前一天,我只是问自己为什么,因为NSTimeZone是正确设置的,对我的国家(意大利,罗马)是正确的,这里是我的代码存根,任何想法?
NSString *dateString = @"03/07/2008";
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setFormatterBehavior:[NSDateFormatter defaultFormatterBehavior]];
[formatter setDateFormat:@"dd/MM/yyyy"];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setTimeZone:[NSTimeZone systemTimeZone]];
NSDate *dateFromString = [formatter dateFromString:dateString];
[formatter release];
Run Code Online (Sandbox Code Playgroud)
dateFromString的结果是2008-07-02 22:00:00 +0000.
我已经寻找其他解决方案,但常见的答案是正确设置时区,在我的情况下,它设置正确但问题仍然存在.
我正在寻找一种以编程方式禁用UITextView水平滚动的方法,通过Interface Builder很容易,但由于我以编程方式设计视图我无法找到方法来实现这一点,我将其用Google搜索为好吧,但我得到的最多是这个:
它不起作用.任何提示?
self.textViewOpenedRect = CGRectMake(20, 20, 280, 130);
self.textView = [[UITextView alloc] initWithFrame: self.textViewOpenedRect];
self.textView.contentInset = UIEdgeInsetsMake(5, 5, 5, 5);
self.textView.delegate = self;
self.textView.backgroundColor = [UIColor clearColor];
self.textView.contentSize = CGSizeMake( self.textView.frame.size.height, self.textView.contentSize.height);
self.textView.alwaysBounceHorizontal = NO;
self.textView.bounces = NO;
Run Code Online (Sandbox Code Playgroud)
更新:显然问题是因为这行代码:
self.textView.contentInset = UIEdgeInsetsMake(5, 5, 5, 5);
Run Code Online (Sandbox Code Playgroud)
我用它在框架和文本之间有一点空间...am我做得好吗?