Tag: cocoa touch

检测时间格式是12小时制还是24小时制

有什么办法来检测应用程序的当前设备是否使用12小时我们的24小时格式,以便我可以使用一个NSDateFormatter 12小时和一个24小时取决于用户语言/位置设置? 就像UIDatePicker检测并显示AM / PMselect器,如果它是12小时格式。

performSelector的返回值:

performSelector的返回值是什么:如果我传递一个select器,返回一个原始types(在对象上),比如NSDateComponents上的“week”(将返回一个int)?

当表重新出现时,UITableView不会自动取消选定的行

正常情况下,当用户从细节视图中popup时, UITableView的选定行将被取消selectanimation。 但是,在我的情况下,我有一个UITableViewembedded到UIViewController我必须在viewWillAppear手动执行它,如下所示: -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; // For some reason the tableview does not do it automatically [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES]; } 为什么是这个以及如何解决?

NSMutableArray对象的总大小

我有一个NSMutableArray拥有一堆对象,我想弄清楚array使用多less内存。 看了几个我知道的调用大小的地方,当我做到这一点,我得到32位(这是自己的NSMutableArray对象的大小)。 示例代码: NSMutableArray *temp = [[NSMutableArray alloc]init]; [temp addObject:objectxyz]; [temp addObject:objectabc]; [temp addObject:object123]; 现在我想知道大小:)

我怎样才能填充左边的整数零?

我有以下variables: NSNumber *consumption = [dict objectForKey:@"con"]; 这将返回42.如何将此数字填充到左侧的10个数字,以零开头。 输出应该看起来像, 0000000042 或者如果它是420, 0000000420

NSURLConnection / NSURLRequest gzip支持

有谁知道NSURLConnection / NSURLRequest是否支持gzip请求。 如果有,你能提供更多的信息吗? 提前致谢!

尝试呈现* on *其视图不在窗口层次结构中

我想在我的应用程序委托(我创build了一个名为showLoginView函数)中的模式视图控制器。 但是每当我尝试调用它时,我都会在XCode中得到一个警告: Warning: Attempt to present <PSLoginViewController: 0x1fda2b40> on <PSViewController: 0x1fda0720> whose view is not in the window hierarchy! 以下是方法代码: – (void)showLoginView { PSLoginViewController *loginViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:NULL] instantiateViewControllerWithIdentifier:@"PSLoginViewController"]; [self.window.rootViewController presentViewController:loginViewController animated:NO completion:nil]; } 我如何将视图添加到窗口层次? 或者,我正在做一些非常错误的事情?

做animateWithDuration:animation:块主线程?

我已经连接下面的两个方法来分离我的用户界面button,但注意到按下“版本1”button后,我不能再次按下button,直到方法内的animation持续时间结束。 我的理解是animation使用自己的线程,以免阻塞主应用程序。 // VERSION 1 -(IBAction)fadeUsingBlock { NSLog(@"V1: Clicked …"); [myLabel setAlpha:1.0]; [UIView animateWithDuration:1.5 animations:^{ [myLabel setAlpha:0.0]; }]; } 旧式版本(如下)确实允许button在animation计时器结束之前被压缩,只需重新设置计时器即可重新开始。 如果这两者都是一样的,我是否错过了一些东西,或者在3.2到4之间有什么变化? // VERSION 2 -(IBAction)fadeUsingOld { NSLog(@"V2: Clicked …"); [myLabel setAlpha:1.0]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.5]; [myLabel setAlpha:0.0]; [UIView commitAnimations]; } 干杯加里

如何打开/closuresiPhone相机闪光?

如何以编程方式打开/closuresiPhone的LED相机闪光灯?

如何返回UINavigationController中的一个视图?

有没有一种方法可以在UINavigationController的堆栈中返回一个视图? 或者以一个特定的标题观看?