我需要在将一些日期,我必须NSString以NSString这种格式:yyyy-MM-dd HH:mm:ss zzz
我写这篇文章的代码:
日期输入:日期---> 27/03/2012
-(NSString *)setDateStringFormat:(NSString *)date
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd/MM/yyyy"];
[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
//[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
NSDate *dateFormatted = [formatter dateFromString:date];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss zzz"];
[formatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
return [formatter stringFromDate:dateFormatted];
}
Run Code Online (Sandbox Code Playgroud)
输出:2012-03-27 00:00:00 GMT
你们都可以看到我得到了约会GMT而不是UTC
某个人有想法吗?
我有一个开发的项目,iOS 5.0现在我需要更新我的项目iOS 6.0.在这样做时,我xcode 4.5抛出的错误如下......
dyld: Library not loaded: @rpath/SenTestingKit.framework/Versions/A/SenTestingKit
Referenced from: /Users/developer/Library/Application Support/iPhone Simulator/6.0/Applications/6EFF12B6-DA80-4DD8-B3CF-B217C5EA63DF/XxxxXxxx.app/xxxxXxxxXxx
Reason: image not found
Run Code Online (Sandbox Code Playgroud)
仍然它运行并在iOS 5设备中完美运行,我试图在iphone Simulator iOS 6.0它运行这个应用程序抛出错误...任何机构有任何想法...提前谢谢...
我的问题是我正在使用字典中的表数据源.这本词典中包含20多个元素.
我需要搜索字典中的元素,我需要将该元素滚动到可见单元格.
我的问题是我找到了元素,但它不在可见区域.我需要将其滚动到可见区域.
我怎样才能获得索引?
collections objective-c nsdictionary nsmutabledictionary ios5
我试图淡出整个视图,但一个特定的subview,这将强调subview更清晰的外观.比方说,如果self.view有5个textfields和2个UIView作为subviews,我想1 UIView加以强调.是否有一种方法可以淡出/在整个自我中使用5 textfields和1 UIView而不触及强调UIView?
我已经尝试过使用方法了
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
Run Code Online (Sandbox Code Playgroud)
如:
[UIView animateWithDuration:0.75
animations:^{
self.view.alpha = 0.5f;
}
completion:^(BOOL finished){self.view.layer.shouldRasterize = NO;}];
Run Code Online (Sandbox Code Playgroud)
但是,似乎整个子视图都受到上面UIView动画的影响.任何建议或提示将不胜感激.
我有一个用户输入时间的选择器视图.当他们向下滚动到第23小时时,我希望小时0显示为下一个项目,并且要重新开始的序列.我怎样才能做到这一点?
这是我当前的选择器视图数据源:
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 3;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
NSArray *sectionContents = [[self dataForDatapickerRows] objectAtIndex:component];
NSInteger rows = [sectionContents count];
NSLog(@"component %d rows is: %d",component,rows);
return rows;
}
- (NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component {
self.dataPickerInstance.backgroundColor=[UIColor whiteColor];
return ([[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]);
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if(component==0)
{
[self setHou:(NSInteger*)[[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]];
}
else if(component==1)
{
[self setMinut:(NSInteger*)[[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]];
}
else if(component==2)
{
[self setSecon:(NSInteger*)[[[self dataForDatapickerRows ]objectAtIndex:component] objectAtIndex:row]];
} …Run Code Online (Sandbox Code Playgroud) 我在将字符串数组转换为货币时遇到问题。
我创建了一个扩展currencyInputFormatting()。但是,逗号被放置在错误的位置。
这是我的代码:-
cell.balanceLabel.text? = (monthlyBalanceStringArray)[indexPath.row].currencyFormatting()
extension String {
// formatting text for currency textField
func currencyFormatting() -> String {
var number: NSNumber!
let formatter = NumberFormatter()
formatter.numberStyle = .currency
formatter.maximumFractionDigits = 2
var amountWithPrefix = self
let regex = try! NSRegularExpression(pattern: "[^0-9]", options: .caseInsensitive)
amountWithPrefix = regex.stringByReplacingMatches(in: amountWithPrefix, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, self.characters.count), withTemplate: "")
let double = (amountWithPrefix as NSString).doubleValue
number = NSNumber(value: (double))
// number = NSNumber(value: (double / 100))
guard number != 0 …Run Code Online (Sandbox Code Playgroud) ios ×4
objective-c ×4
iphone ×2
xcode ×2
collections ×1
fadeout ×1
ios5 ×1
ios6 ×1
ipad ×1
nsdictionary ×1
swift ×1
uipickerview ×1
uiview ×1
xcode4.5 ×1