我正试图从nsdate对象获取本地化的工作日
+ (NSString *)localizedWeekdayForDate:(NSDate *)date
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
dateFormatter.dateFormat = [NSDateFormatter dateFormatFromTemplate:@"EEEE" options:0 locale:[NSLocale localeWithLocaleIdentifier:language]];
NSString *formattedDateString = [dateFormatter stringFromDate:date];
return formattedDateString;
}
Run Code Online (Sandbox Code Playgroud)
语言字符串总是"en"...即使你的设备语言不是英语......我试过[NSLocale currentLocale]; 以及首选的语言......这也行不通..
有什么建议?
我刚刚将XCode更新到最新版本以使用iOs 7.1 Simulator.自从我不能再建造这个项目了
Undefined symbols for architecture i386:
"VRightWebiOS::SetSecurityCallbackDelegate(id<VRSecurityCallback>)", referenced from:
-[VXManager open:securityDelegate:] in VXManager.o
Run Code Online (Sandbox Code Playgroud)
如果我尝试为设备构建,我会得到相同的东西,但使用架构arm7而不是i386.这在更新之前没有发生,我没有修改项目文件,因为......
我在iOs应用程序中使用页面视图控制器.如何从此控制器中删除点?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.dontShowChecked = NO;
self.imagesArray = @[ ..];
self.textsArray = @[ ........
];
// Create page view controller
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"WTPageController"];
self.pageViewController.dataSource = self;
WTDetailViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
// Change the size of page view controller
CGFloat delta = [[PSDeviceInfo sharedInstance] is_iPhone] ? 50. : 50;
self.pageViewController.view.frame = CGRectMake(0, 40., self.view.frame.size.width, self.view.frame.size.height - delta);
[self.view …Run Code Online (Sandbox Code Playgroud) 我正在尝试将旧的 Objective-C 项目更新为 swift。我需要生成高斯随机数。在 Objective-c 中我使用了这个:
double gaussrand()
{
static double V1, V2, S;
static int phase = 0;
double X;
if(phase == 0) {
do {
double U1 = (double)rand() / RAND_MAX;
double U2 = (double)rand() / RAND_MAX;
V1 = 2 * U1 - 1;
V2 = 2 * U2 - 1;
S = V1 * V1 + V2 * V2;
} while(S >= 1 || S == 0);
X = V1 * sqrt(-2 * log(S) / S);
} …Run Code Online (Sandbox Code Playgroud) 为什么会崩溃?
CategoryOfExpense *newCatEx = (CategoryOfExpense *) [NSEntityDescription entityForName:kCategoryOfExpense inManagedObjectContext:moc];
newCatEx.name = self.nameTextField.text; <- crashes here
newCatEx.icon = [NSData dataWithData:UIImagePNGRepresentation(self.iconImageView.image)];
Run Code Online (Sandbox Code Playgroud)
错误是:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Can't modify an immutable model.'
Run Code Online (Sandbox Code Playgroud) 这是检查serverOnNowDate是否在publishedStartTime和publishedEndTime之间的好方法吗?
return !( [self.publishedStartTime compare:serverOnNowDate] == NSOrderedDescending
|| [self.publishedEndTime compare:serverOnNowDate] == NSOrderedAscending );
Run Code Online (Sandbox Code Playgroud) 我有2个视图控制器注册,以接收设备方向更改通知.`
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(repositionView)name:UIDeviceOrientationDidChangeNotification object:nil];
`
在重新定位视图方法中,我有:
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation)) {
NSLog(@"view (%@) will set orientation landscape",self);
// do smt
} else {
NSLog(@"view (%@) will set orientation portrait",self);
//do smt else
}
Run Code Online (Sandbox Code Playgroud)
当方向改变时,它们都在记忆中
2013-11-27 17:37:54.277 App[13782:70b] view (<ViewController: 0xbf09950>) will set orientation landscape
2013-11-27 17:37:54.286 App[13782:70b] view (<ViewController: 0xc095e40>) will set orientation portrait
2013-11-27 17:38:17.318 App[13782:70b] view (<ViewController: 0xbf09950>) will set orientation portrait
2013-11-27 17:38:20.123 App[13782:70b] view (<ViewController: 0xc095e40>) will set orientation landscape
Run Code Online (Sandbox Code Playgroud)
只有一个接收正确的方向.为什么是这样 …
我需要在表格视图单元格中设置一些标签字体和颜色.
我在用:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
// Initialization code
[self customize];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
在自定义方法中,我将两个标签设置为具有相同的字体和文本颜色
self.label1.textColor = somecolor;
self.label2.textColor = somecolor; // same color
Run Code Online (Sandbox Code Playgroud)
问题是,他们最终有不同的颜色(一个深灰色,另一个浅灰色)我检查了笔尖,并设置了出口.通过单步执行代码,我注意到标签在那时是零.那他们在哪里实例化?为什么他们没有相同的颜色?
我有一个方法需要在用户第一次运行应用程序(在一个月内启动或从后台返回应用程序)时调用?做这个的最好方式是什么 ?(这是一个iOs应用程序)...我猜这是需要调用它的代理