Tag: 目标C

无法获得user_events脸书的权限

我正在尝试获取用户所创build的所有事件,我试图请求访问user_events的权限。 不过到目前为止,facebook并没有要求用户访问事件的权限。 我已经检查了testing用户应用权限configuration文件,我的应用只获取configuration文件信息,但不是事件设置。 我使用的Facebook的SDK是3.19 if ([FBSession.activeSession.permissions indexOfObject:@"user_events"]==NSNotFound) { [FBSession.activeSession requestNewReadPermissions:@[@"user_events"] completionHandler:^(FBSession *session, NSError *error) { if (!error) { action(); } else if (error.fberrorCategory != FBErrorCategoryUserCancelled) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Permission denied" message:@"Unable to get permission to post" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } }]; } else { action(); }

AVAudioPlayer在后台没有响应

当我的应用程序收到voip通知时,我在后台播放audio。 但AVAudioPlayerperformance怪异,有时会播放audio,有时并非没有任何错误。 多数民众赞成我是如何玩: func playAudio() { // Set the sound file name & extension let alertSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("testAudio", ofType: "wav")!) // Play the sound do { try audioPlayer = AVAudioPlayer(contentsOfURL: alertSound) audioPlayer.delegate = self if (audioPlayer.prepareToPlay()) { audioPlayer.play() } else {NSLog("there is error")} } catch { NSLog("there is \(error)") } } 我在我的AppDelegate应用程序函数中初始化AVAudioSession: do { […]

从Login ViewController提供先前活动的ViewController

我有4个视图控制器:loginVC – > homeVC – > aVC – > bVC 。 让我们假设用户目前在bVC视图控制器,并决定切换到另一个应用程序。 当用户切换回我的应用程序,我想呈现loginVCauthentication用户。 一旦通过authentication,先前的bVC视图控制器将呈现给用户以继续他/她正在做的任何事情。 我没有在我的项目中使用导航控制器。 在applicationDidBecomeActive:方法中,我能够呈现loginVC视图控制器,但是一旦用户通过身份validation,我该做什么来呈现bVC视图控制器? 我认为应用程序从主动退出时, bVC仍然在堆栈中? // AppDelegate.m -(void) applicationDidBecomeActive: (UIApplication*) application { NSString *storyboardId = @"LoginIdentifier"; self.window.rootViewController = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:storyboardId]; } // loginVC.m -(void)authenticateSuccessful { // This doesn't do anything… as I want to present bVC [self dismissViewControllerAnimated:YES completion:nil]; }

如何在iOS中从格式化的string中获取date和时间

我有一个NSString“dateString”,其中包含给定格式的date和时间。 "MM/dd/yyyy HH:mm:ss a" 。 我想使用NSDateFormatter从dateString中获取数据,然后我试图显示一个string"strDate" 。 我能够获取数据,但唯一的问题是,我没有得到"hour"地方正确的价值。 例如: dateString = 1/23/2015 7:06:37 AM strDate = 01/23/2015 00:06:37 am 如何解决这个问题。 提前致谢。 这是我的代码: -(NSString *)getDateQuestion:(NSString *)dateString { NSLog(@"dateString = %@",dateString); //NSString to NSDate NSDate *datefromString = [[NSDate alloc] init]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT+5:30"]]; [dateFormatter setTimeZone: [NSTimeZone systemTimeZone]]; [dateFormatter setDateFormat:@"MM/dd/yyyy HH:mm:ss a"]; […]

当closures视图启动位置服务通知错误发生

我创build了一个使用这个项目的小应用程序,因为它的核心是: https://github.com/dsdavids/TTLocationHandler 它一直工作得很好,直到我已经移动从应用程序中的另一个视图移动位置服务。 什么应用程序正在做:当它启动时,您可以点击开始button和( 在模拟器位置必须启用 )在移动的地图上的移动路线显示。 当我在第二个视图中移动开始行动时,问题出现了。 在第二个视图中,我只想启动位置服务并closures它。 问题是,当我开始定位在第二个视图我得到错误(应用程序崩溃EXC_BAD )在这里: TTLocationHandler … dispatch_async(dispatch_get_main_queue(), ^{ if (OUTPUT_LOGS) NSLog(@"Sending notification out"); NSNotification *aNotification = [NSNotification notificationWithName:LocationHandlerDidUpdateLocation object:[locationToSave copy]]; [[NSNotificationCenter defaultCenter] postNotification:aNotification]; }); … 我认为这是因为我closures了第二个视图(查看启动服务), TTLocationHandler仍然试图发送一些东西。 为了更好地理解我的问题,我已经在git hub上添加了项目: https://github.com/1110/common-location-features 您可以下载它,并从第二个视图运行启动服务,当closures该视图的应用程序将在几秒钟内崩溃。 如果有人能find一点时间告诉我我在做什么错,我会非常感激,因为我确信这是一件小事,我可能做错了。 整个代码在SecondViewController.m 谢谢

在ObjectiveC中连接audio缓冲区

首先我是c和c的新蜜蜂 我尝试去掉一个audio缓冲区并绘制它的graphics。 我使用audio单元callback来获取audio缓冲区。 callback带来了512帧,但471帧后,它带来0.(我不知道这是正常的,它用来带471帧充满数字,但现在不知怎的512帧47之后0。请让我知道如果这是正常的) 无论如何。 我可以从callback中获取缓冲区,应用fft并绘制它。 这工作完美。 下面是结果。 只要我在每个callback中获得缓冲区,graphics就非常平滑 但在我的情况下,我需要3秒的缓冲区,以应用fft和绘制。 所以我尝试连接来自两个callback的缓冲区,然后应用fft并绘制它。 但结果并不像我所期望的那样。 而上面的一个在logging过程中非常stream畅和精确(只有在18和19 kHz的幅度变化),当我连接两个缓冲区时,仿真器主要显示两个不同的视图,它们之间交换的速度非常快。 他们显示在下面。 当然,他们基本上显示18和19千赫兹。 但我需要精确的khz,所以我可以为我工作的应用程序应用更多的algorithm。 这是我的代码在callback //FFTInputBufferLen, FFTInputBufferFrameIndex is gloabal //also tempFilteredBuffer is allocated in global //by the way FFTInputBufferLen = 1024; static OSStatus performRender (void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { UInt32 bus1 = 1; […]

Facebook iOS SDK 4.0.1“您必须将此应用升级到Graph API v2.x”

我正在尝试升级一个Facebook应用程序使用即将被弃用的1.0 API到当前的。 我用当前的(4.0.1)replace了框架(FBSDKCoreKit,FBSDKLoginKit)。 当我使用web-fallbacklogin时,这样做会升级应用程序。 但是,当我通过Facebook应用程序login时,我仍然得到弃用警告。 这是我的(抽象)代码: – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSLog(@"SDK version: %@", [FBSDKSettings sdkVersion]); // Prints "SDK version: 4.0.1 UIViewController *vc = [UIViewController new]; FBSDKLoginButton *loginButton = [FBSDKLoginButton new]; loginButton.frame = CGRectMake(10, 200, 300, 50); [vc.view addSubview:loginButton]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = vc; [self.window makeKeyAndVisible]; return YES; } […]

iOS:在Objective-C ++中定义和使用C ++

任何人都可以告诉我如何定义和使用iOS 5.x中的BinaryWriter和BinaryReader ( 从GitHub上的OpenFrameworks项目 )C ++类 – > Objective-C的? 我做的事: AppDelegate.h #import <UIKit/UIKit.h> #import "Poco/BinaryWriter.h" @interface AppDelegate : UIResponder <UIApplicationDelegate>{ Poco::BinaryWriter *_myBinaryWriter; } @property (strong, nonatomic) UIWindow *window; @end AppDelegate.mm #import "AppDelegate.h" @implementation AppDelegate @synthesize window = _window; – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; _myBinaryWriter = new Poco::BinaryWriter(NULL, […]

IOS Developpement:背景BLE扫描

我目前正在试图开发一个背景蓝牙相关的应用程序,我在后台扫描有一些麻烦。 我跟着整个苹果IOS蓝牙背景教程,但我不知道为什么扫描不能在后台工作(我的info.plist正确设置pipe理BLE后台任务,中央和外围)。 到目前为止我所testing的是: 1 – 当我的两个设备在范围内和前景,扫描效果很好。 2 – 当外围设备在后台,中央在前台激活时,扫描也可以正常工作,外围设备可以检测到。 麻烦来了 3 – 首先启动我的外围设备,然后将应用程序置于后台。 然后在外围设备上,我closures蓝牙 ,启动应用程序,我把它放在后台,然后打开蓝牙。 在我的代码中, -(void)centralManagerDidUpdateState:(CBCentralManager *)central调用扫描[centralmgr scanForPeripheralsWithServices:[NSArray arrayWithObject:servicesUUID] options:scanOptions]; ,在前台完美运行的function。 但是什么都没有发生,外围设备从未被中央检测到。 4 – 我启动中央,蓝牙激活,我把它放在后台。 然后,我把我的外围设备,我走出了蓝牙范围(在具体情况下,我去我的超市买了一些啤酒淹死我的悲伤) ,我在那里启动 – 也蓝牙激活 – 我把它放在背景和我回到我周边的附近。 再一次没有发生,中央没有检测到外围设备。 而且,在案例3和案例4之后,如果我只把中央放在前台(外围设备停留在后台),检测将重新开始,而不做其他任何事情。 就好像在案例4中成功触发了扫描,但是等待应用程序激活以实际开始检测其他设备。 有人对如何解决问题有所了解吗? 谢谢! 诗:我为我的英语道歉,我有点生疏

如何注销instagram API?

instagram API身份validation页面没有关于如何注销用户的任何信息:在使用该API的iOS应用程序中,我该如何让用户注销?