iOS:didReceiveMemoryWarning的帮助:

我是我的开发过程中追踪崩溃和内存泄漏的一部分。 作为一个策略,你是否把任何NSLog的消息或一些这样的通知didReceiveMemoryWarning: 这个方法的文档相当稀less。 是否准确地说,在发生崩溃之前,UIViewController会触发该方法? 即使是与仪器一起前进,这是一个起点吗?

为什么不从NSNotificationCenter删除观察者:addObserverForName:usingBlock被调用

我很困惑,为什么在下面的代码中永远不会删除观察者。 在我看来,我有以下几点: -(void)viewDidAppear:(BOOL)animated{ id gpsObserver = [[NSNotificationCenter defaultCenter] addObserverForName:FI_NOTES[kNotificationsGPSUpdated] object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note){ NSLog(@"run once, and only once!"); [[NSNotificationCenter defaultCenter] removeObserver:gpsObserver]; }]; } 观察者永远不会被移除,并且每次发送通知时都会输出语句。 任何人可以提供任何指导?

如何将CGFontRef转换为UIFont?

我想为UILabel使用自定义字体。 自定义字体由文件加载: NSString *fontPath = … ; // a TTF file in iPhone Documents folder CGDataProviderRef fontDataProvider = CGDataProviderCreateWithFilename([fontPath UTF8String]); CGFontRef customFont = CGFontCreateWithDataProvider(fontDataProvider); CGDataProviderRelease(fontDataProvider); 我如何将CGFontRef转换为CGFontRef来使用[UILabel setFont:] ?

UIWebView中的cookie被接受了吗?

我不得不为你质疑。 1:我在iPhone应用程序中使用UIWebView 。 我不希望用户能够在新闻中添加评论。 但是,要发表评论,他们必须login。 如果没有,我怎样才能在UIWebView接受cookie? 2: UIWebView创build的Cookie是否可用于其他视图中的其他UIWebView ? 例如:我有我的LoginViewController ,embedded了UIWebView ,我的用户可以login/注销。 如果他们在这个视图中login,Cookie将仍然在CommentViewController可用? 如果没有,我怎么能做到这一点? 提前致谢 !

为什么在iOS7中UIWebView canGoBack = NO?

我将这个网站embedded到我的应用程序中,如下所示: NSString *url = [NSString stringWithFormat:@"https://mobile.twitter.com/search?q=%@", @"@test OR #test"]; url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [self.twitterWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]; self.twitterWebView.scalesPageToFit = YES; 而且我有2个button可以在这个网站上前进和后退。 我在打电话 [self.twitterWebView goBack]; 和 [self.twitterWebView goForward]; 因此。 这在iOS 6上工作正常,但在iOS 7上,我的web视图的canGoBack和canGoForward属性是NO,因此我的后退和前进button不起作用。 作为一个侧面说明,当应用程序第一次安装,并在第一次加载页面,我的button的工作。 但是当我再次运行我的应用程序,当我点击网站上的链接时,我的web视图的canGoBack属性开始始终返回NO。 我该如何解决这个问题? 编辑 :我上传了一个小型testing应用程序,演示了我的问题。 你可以从这里下载。 请在iOS 7模拟器上运行应用程序,请参阅第一次安装应用程序后退button。 然后退出,再次运行应用程序,你会发现它会停止工作。 顺便问题似乎是关于Twitter的移动网站。 你可以尝试另一个网站地址,看看。

推送通知-didFinishLaunchingWithOptions

当我发送一个推送通知,我的应用程序打开或在后台,我点击推送通知,我的应用程序redirect到PushMessagesVc viewController ( 按照预期 ) 我使用如下代码: -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { UIStoryboard *mainstoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; PushMessagesVc *pvc = [mainstoryboard instantiateViewControllerWithIdentifier:@"PushMessagesVc"]; [self.window.rootViewController presentViewController:pvc animated:YES completion:NULL]; } 在上面的代码/场景中没有问题,但如果应用程序已closures,并且单击推送通知,则应用程序在此情况下不redirect我的PushMessagesVc viewController , PushMessagesVc应用程序停留在主屏幕上。 对于第二种情况,我使用下面的代码: – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { sleep(1); [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeNone)]; [UIApplication sharedApplication].applicationIconBadgeNumber = 1; NSDictionary *userInfo = [launchOptions valueForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"]; […]

Instagram API在400次错误的请求错误成功login后阻止redirect到iOS应用

我试图将Instagramlogin集成到我的应用程序中以获取login用户的详细信息,我已经在Instagram上注册了我的应用程序并获得了我的客户ID,然后在项目设置中添加了一个新的URL Type,其标识符为: igxxxx (其中xxxx是我的客户端ID),我也设置redirectURI为( xxxx://authorize ),一旦我成功login(使用web视图),Instagram显示一个白色的空白页面( 400 Bad Request )但是,当我将redirectURI更改为其他任何内容时,在成功login后它将打开而不会出现问题。 如何在Instagram上login后将用户redirect到应用程序。 ps我使用这个库来缓解事情。 提前致谢。

如何停止在iOS Crash Log中添加“<redacted>”的符号

我从App Store中的iPhone应用程序(通过iTunes Connect获取)发现了崩溃日志,在符号化之后CodeData和CoreFoundation中有一堆“<redacted>”方法名。 来自iTunes Connect的原始崩溃日志文件如下所示: Last Exception Backtrace: 0 CoreFoundation 0x34a0929e __exceptionPreprocess 1 libobjc.A.dylib 0x32d1997a objc_exception_throw 2 CoreData 0x3631fec2 -[NSSQLCore _obtainOpenChannel] 3 CoreData 0x363cfd9c newFetchedRowsForFetchPlan_MT 4 CoreData 0x363b3be6 -[NSSQLCore newFetchedPKsForSourceID:andRelationship:] 5 CoreData 0x363a6008 -[NSSQLCore newValueForRelationship:forObjectWithID:withContext:error:] 6 CoreData 0x3635690a -[NSFaultHandler retainedFulfillAggregateFaultForObject:andRelationship:withContext:] 7 CoreData 0x36326d48 -[_NSFaultingMutableSet willRead] 8 CoreData 0x3632767c -[_NSFaultingMutableSet allObjects] 日志看起来像这样在我的Mac上象征性的: Last Exception Backtrace: 0 […]

强制使用自定义/货币模式的iOS数字键盘

是否有可能强制iOS设备显示数字键盘, 而使用自定义模式作为inputtypes ? 我的input模式: <input id="price" class="numeric" pattern="\d+((\.|,)\d{1,2})?" name="price" title="" data-mini="true" data-clear-btn="true" autocomplete="off" autofocus /> 我想input一个像“14.99”这样的货币值,并在iOS设备上显示一个可以访问数字的键盘 <input type='number' /> <input pattern='[0-9]*' /> <input pattern='[\d]*' /> 都是缺less小数点符号和(或)在添加小数点时不作为数字validation。 另一种方法可能是在正确的位置创build十进制符号的JavaScript函数,例如按1-> 2-> 9-> 9按键创build()0.01-> 0.12-> 1.29-> 12.99,但是这需要input字段为type='text' – >这里显而易见的问题是在聚焦input字段时显示文本键盘。 我该如何解决这个问题? 编辑 环境: JQM 1.3.2 jquery 1.8.2

捏缩放在scrollView内的UIImageView的影响?

我正在使用故事板(iOS 6.0)为我的应用程序创build照片库查看器。 这是我的imageViewController在故事板中的设置: 我已经确保在imageView和scrollView上启用userInteraction和多个触摸。 我想要做的是,捏,我想放大到imageView(最大比例3),并能够平移。 这是我目前有,但是,即使捏手势检测到规模不会改变。 – (IBAction)imagePinched:(id)sender { if (pinchRecognizer.state == UIGestureRecognizerStateEnded || pinchRecognizer.state == UIGestureRecognizerStateChanged) { NSLog(@"gesture.scale = %f", pinchRecognizer.scale); CGFloat currentScale = self.fullScreenView.frame.size.width / self.fullScreenView.bounds.size.width; CGFloat newScale = currentScale * pinchRecognizer.scale; if (newScale < 1) { newScale = 1; } if (newScale > 3) { newScale = 3; } CGAffineTransform transform = […]