Tag: Objective C

UITapGestureRecognizer – 让它在接触下工作,而不是接触?

我使用tap事件的时间非常敏感,所以我很好奇,如果可以在用户简单触摸的时候激活UITapGestureRecognizer,而不是要求他们触摸起来。

使用AFNetworking 2.0上传图像

这个我正在撞墙。 我想从库中selectUIImage并将其上传到服务器,就像使用<form action="http://blabla.request.cfm" method="post" enctype="multipart/form-data"> 。 而不是成功,我得到这个错误: 错误=错误域= NSCocoaErrorDomain代码= 3840“操作无法完成。(cocoa错误3840.)”(JSON文本没有开始数组或对象和选项允许片段不设置。)UserInfo = 0x145e5d90 {NSDebugDescription = JSON文本没有以数组或对象和选项开始,以允许片段未设置。} 我试过这种方式: -(void)uploadPhoto{ NSString *path = @"http://blabla.request.cfm"; NSData *imageData = UIImageJPEGRepresentation(self.imageView.image, 0.9); int priv = self.isPrivate ? 1 : 0; NSDictionary *parameters = @{@"username": self.username, @"password" : self.password, @"private" : @(priv), @"photo" : imageData}; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager POST:path […]

embeddedYouTubevideo

我已经通过在互联网上find的代码片段embedded了来自YouTube的video,以下是我使用的代码: @interface FirstViewController (Private) – (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame; @end @implementation FirstViewController – (void)viewDidLoad { [super viewDidLoad]; [self embedYouTube:@"http://www.youtube.com/watch?v=l3Iwh5hqbyE" frame:CGRectMake(20, 20, 100, 100)]; } – (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame { NSString *embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>"; NSString *html […]

UIButton长按活动

我想模仿长按button,我该怎么做? 我觉得需要一个计时器。 我看到UILongPressGestureRecognizer但我怎么能利用这种types?

仅在iOS中首次启动时显示屏幕

Tweetbot和清除显示的应用程序的第一个开始小教程屏幕上的应用程序如何工作。 只有在第一次启动应用程序时才会popup小教程的屏幕(1次) 如何以及我能做出类似的事情? 任何人都可以把我推向正确的方向吗? 查看我的意思是:

如何用Swift播放本地video?

我有一个简短的mp4video文件,我已经添加到我当前的Xcode6testing版项目。 我想在我的应用程序中播放video。 经过几个小时的search,我找不到任何远程帮助。 有什么办法可以用Swift来完成吗?还是你必须使用Objective-C? 我能指出正确的方向吗? 我不能是唯一想知道的人。

iOS的UITextView或UILabel与可点击链接的行动

我想用一些带有2个可点击链接的文本来制作UILabel或者UITextView 。 没有链接到网页,但我想链接这样的行动,我会用UIButton做。 我所看到的所有例子都是网页浏览的链接,但我不想要。 同样,文本将被翻译成其他语言,所以职位必须是dynamic的。 想要做到这一点:

我如何从我的原生应用程序中启动Google Maps iPhone应用程序?

Apple开发者文档 (现在链接已经失效)解释说,如果您在网页中放置链接,然后在iPhone上使用Mobile Safari时单击该链接,则会启动与iPhone一样提供的Google地图应用程序。 我如何才能在自己的本地iPhone应用程序(即不通过Mobile Safari的网页)中启动具有特定地址的Google Maps应用程序,方法与点击联系人中地址启动地图的方式相同? 注意:这只适用于本设备。 不在模拟器中。

didRegisterForRemoteNotificationsWithDeviceToken不在ios8中调用,但didRegister …设置是

我跟着这个线程 ,但方法didRegisterForRemoteNotificationsWithDeviceToken仍然没有被调用: 该文件说: 在调用UIApplication对象的registerForRemoteNotifications方法后,应用程序在设备注册成功完成时调用此方法 didRegisterUser似乎很好,但did register notif 。 这是我在AppDelegate中的代码(应用程序版本是8.1): – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //register notif UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound); UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil]; [application registerUserNotificationSettings:settings]; return YES; } – (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { //register to receive notifications [application registerForRemoteNotifications]; NSLog(@"didRegisterUser"); } -(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { […]

在Swift中使用CCCrypt(CommonCrypt)问题

我正在将一个工作的Objective-C类别(NSData + AESCrypt.m)移植到Swift中,并且发现了一个指针问题。 Swift中encryption部分的代码编译正确,但生成一个运行时EXEC_BAD_ACCES错误。 我到目前为止的代码是(我试图尽可能解剖代码): let key = "123456789012345678901234567890120" let keyLength = UInt(kCCKeySizeAES256 + 1) let keyPointer = strdup(key) // Convert key to <UnsafeMutablePointer<Int8> let message = "Don´t try to read this text. Top Secret Stuff" let data = (message as NSString).dataUsingEncoding(NSUTF8StringEncoding) let dataBytes = data?.bytes let length = data?.length let dataLength = UInt(length!) let […]