将在Interface Builder中创build的UITabBarController设置为委托

我使用Tab Bar模板创build了我的iOS应用程序,所以这里是带有条形button的UITabBarController。 一个问题是如何将其设置为委托。 我在SO发现它必须在AppDelegate中以编程方式设置,但是我相信这是不可能的,因为我没有访问Tab Bar Controller作为sockets。 我添加了@interface (ViewController和AppDelegate)的适当值,但不知道下一步该怎么做。 @interface ViewController : UIViewController <UITabBarControllerDelegate> 我希望我不必摆脱整个应用程序模板,并可以将在IB中创build的Tab Bar Controller设置为委托。 正是我想让它委托创build选项卡上select这样的事件: – (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController; 任何想法?

如何确定用户第一次运行应用程序?

我最近遇到了iOS应用程序的问题。 在我的应用程序中,指令视图将在第一次运行时出现,然后隐藏。 我怎样才能实现这个效果?

ios mapkit通过点击地图closures注释标注

我有一个mapkit应用程序,它将注释放在地图上,当你按下它时,它会显示标题属性的标注。 这工作正常,但用户不能closures它们。 他们保持开放,直到他们点击另一个注释。 我不能让用户可以在地图上点击其他地方(或再次点击注释)closures它吗? 我有一种感觉,这是默认设置,所以也许我正在做的东西是填塞? 我有一个手势识别器,我用它来检测一些地图水龙头 UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; tap.numberOfTapsRequired = 1; [self.mapView addGestureRecognizer: tap]; 这引发了这个问题: – (void)handleTap:(UITapGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { CGPoint tapPoint = [sender locationInView:sender.view.superview]; CLLocationCoordinate2D coordinate = [self.mapView convertPoint: tapPoint toCoordinateFromView: self.mapView]; if (pitStopMode && !pitStopMade){ pitStopMade = YES; InfoAnnotation *annotation = [[InfoAnnotation alloc] initNewPitstopWithCoordinate:coordinate]; […]

如何将swift Dictionary转换为NSDictionary

我试图将一个[String : String] (一个Swift字典)转换为NSDictionary ,稍后用于生成一个string的JSON库 var parcelDict = ["trackingNumber" : parcel.number, "dstCountry" : parcel.countryCode]; if (parcel.postalService != nil) { parcelDict["postalService"] = parcel.postalService; } var errorPtr: NSErrorPointer let dict: NSDictionary = parcelDict var data = NSJSONSerialization.dataWithJSONObject(dict, options:0, error: errorPtr) as NSData return NSString(data: data, encoding: NSUTF8StringEncoding) 但let dict: NSDictionary = parcelDict不起作用 let dict: NSDictionary = parcelDict […]

强制设备旋转时+ attemptRotationToDeviceOrientation失败

根据这里的UIViewController文档, https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/clm/UIViewController/attemptRotationToDeviceOrientation 使用[UIViewController attemptRotationToDeviceOrientation]强制系统尝试将界面旋转到新的方向。 我试图强制从纵向到横向的界面旋转: 在尝试旋转之前设置forceLandscape标志 调用[UIViewController attemptRotationToDeviceOrientation] 在我的视图控制器中实现-supportedInterfaceOrientations并检查标志以更改支持的方向,例如 这迫使-supportedInterfaceOrientations再次被调用,看起来像 – (NSUInteger)supportedInterfaceOrientations { return self.forceLandscape ? UIInterfaceOrientationMaskLandscapeLeft : UIInterfaceOrientationMaskPortrait; } 即使正在调用-supportedInterfaceOrientations并返回新的方向,接口也不会旋转。 我已经确认该项目允许所有的方向,并且这个视图控制器是窗口的根视图控制器。 有没有其他人遇到这个问题,并find一个解决scheme? 我知道所有的窍门,以解决这个问题(提交和解雇模态等),但我希望有一个干净的解决scheme,如果可能的话。 我已经在iOS 6和7上validation了这个问题。 以下是完整的代码重现: @interface ALTViewController () @property (nonatomic, assign) BOOL forceLandscape; @end @implementation ALTViewController – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.forceLandscape = NO; […]

iOS应用内购买自动续订订阅免费试用选项不可用?

从苹果的文档可以为用户提供免费试用,之后他们将在试用结束后自动收费 如果您提供免费试用,则会在用户订阅时开始。 免费试用结束后,系统会自动收费,除非他们已经closures了自动更新function。 如果您select提供免费试用,则会显示一个下拉菜单,让您select免费试用期。 http://developer.apple.com/library/mac/#documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/13_ManagingIn-AppPurchases_Robert/ManagingIn-AppPurchases.html 现在,当我创build新的自动续订订阅时,我看不到此选项可用。 我看到这样的屏幕,如文档中所示 有人知道在哪里启用或甚至可能吗? 还是我必须通过保存免费试用开始date来手动开发function?

CLLocationManager,而应用程序处于后台状态

我的问题是:是否CLLocationManager继续运行,而我的应用程序是不活动的?

captureStillImageAsynchronouslyFromConnection没有JPG中介

我试图从相机中获得尽可能好的图像,但只能findcaptureStillImageAsynchronouslyFromConnection示例,然后直接进入: NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer]; UIImage *image = [[UIImage alloc] initWithData:imageData]; JPEG是有损的,所有,有没有办法将数据作为PNG,甚至只是RGBA(BGRA,你有什么?)。 AVCaptureStillImageOutput似乎没有任何其他NSData *方法…. 实际上看着CMSampleBufferRef,它似乎已经被locking为JPEG〜 formatDescription = <CMVideoFormatDescription 0xfe5e1f0 [0x3e5ac650]> { mediaType:'vide' mediaSubType:'jpeg' mediaSpecific: { codecType: 'jpeg' dimensions: 2592 x 1936 } extensions: {(null)} } 有没有其他的方式来获取全面的照片,并获得原始数据?

IOS:在后台播放声音

我正在一个小应用程序,我想要手机播放来自我的位置控制器的事件的声音文件。 问题是,当应用程序处于后台模式时,AVAudioPlayer不启动audio文件,但代码已经调度,获得NSLog输出。 另一件事是它在模拟器,但不是在手机上。 不是吗? 这是我的代码来播放文件: – (void)tryPlayTaleSound:(NSString*)fileName { NSString *backgroundMusicPath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"mp3"]; NSURL *backgroundMusicURL = [NSURL fileURLWithPath:backgroundMusicPath]; NSError *error; backgroundMusicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:backgroundMusicURL error:&error]; // Check to see if iPod music is already playing //UInt32 propertySize = sizeof(otherMusicIsPlaying); //AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying, &propertySize, &otherMusicIsPlaying); // Play the music if no other music is playing […]

如何使私人/自定义URL协议的jQuery GET / AJAX请求?

在Mac和iOS平台上, 可以通过自定义URIscheme/ NSURLProtocol与本机运行时进行双向交换 。 例如..要从一个本地的Objective-C方法请求一个NSImage ,你可以注册你的自定义处理程序(一个简单的string,在这里我用“ mycustomprotocol ”)与Webkit /你的WebView NSView ,并从JS调用它… var theURL = 'mycustomprotocol:///' + (textField.value); img.innerHTML = '<img src="'+theURL+'" id="string"/>'; 我会喜欢能够使用jQuery做请求,因为在这一点上,它比90年代风格的JS更为熟悉..但是据我所知,在网上, $.get和$.ajax只做http(s) 。 会喜欢的东西 javascript:document.location = 'mycustomprotocol://' 重写jQuery的URL处理? 当我谈到JavaScript的时候,我觉得这是一个愚蠢的行为,我相信这很容易做到。我相信这是整个jQuery移动框架是如何实现的(通过私有URI的)。所以,为什么没有什么在谷歌或所以呢,对吧? 我可以从我的姐姐朋友那里得到一些帮助吗?