适用于youtubeembedded式video的iOS 6.0+自动转换

我只想在我的iOS应用程序的所有视图控制器中支持垂直方向。 但是,我在其中一个视图控制器中embedded了一个YouTubevideo,当select该video占用全屏幕时,我希望用户能够水平定位他/她的手机,使video扩展为全屏。 编辑:我试图从iOS 6中使用以下代码从Autorotate有奇怪的行为 : – (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return self.fullScreenVideoIsPlaying ? UIInterfaceOrientationMaskAllButUpsideDown : UIInterfaceOrientationMaskPortrait; } 并在我的视图控制器呈现UIWebView / YouTube框架,我有我的viewDidLoad这个代码: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowNowVisible:) name:UIWindowDidBecomeVisibleNotification object:self.view.window ]; – (void)windowNowVisible:(NSNotification *)notification { AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate]; appDelegate.fullScreenVideoIsPlaying = !(appDelegate.fullScreenVideoIsPlaying); } 但是,当用户按下全屏YouTubevideo完成时,如果他/她仍然具有水平的电话,则呈现视图控制器也保持水平(我希望当前视图控制器是纵向的)。 这是一个比赛fullSreenVideoIsPlayingvariables,这是不够快的更新,使我的呈现视图控制器是肖像。 任何有关如何实现这一点的反馈将不胜感激。 谢谢!

当应用程序进入后台时如何保持NSTimer?

我在这里,因为没有find我的问题的任何解决scheme:( 我正在做一个简单的应用程序,我必须发送(通过套接字)一些信息到服务器(如GPS升/ L,准确性,电池电量等)。 当应用程序在前台时,当前的代码工作正常。 myTimer = [NSTimer scheduledTimerWithTimeInterval: 2.0 target:self selector: @selector(sendPosToServer:) userInfo:nil repeats: YES]; myTimer2 = [NSTimer scheduledTimerWithTimeInterval: 3.0 target:self selector: @selector(sendBatteryToServer:) userInfo:nil repeats: YES]; myTimer3 = [NSTimer scheduledTimerWithTimeInterval: 5.0 target:self selector: @selector(sendResToServer:) userInfo:nil repeats: YES]; myTimer4 = [NSTimer scheduledTimerWithTimeInterval: 5.0 target:self selector: @selector(sendQResToServer:) userInfo:nil repeats: YES]; myTimer5 = [NSTimer scheduledTimerWithTimeInterval: 3.0 target:self selector: […]

Swift在超类函数中从相应的子类调用类函数

我想在超类中实现init(coder aDecoder: NSCoder!) ,并在运行时通过在超类的特定子类上调用一个类方法来在所有子类中使用它。 MySuperClass class func dummyDict() -> NSDictionary init(coder aDecoder: NSCoder!) { for(key,value) in self.class.dummyDict(){ ——————– ^ | | Get this from the corresponding subclass at runtime! NSLog("encoding \(value) for key \(key)") } } MySuperClass子类可能在运行时访问类函数dummyDict()吗?

自动布局约束更改不animation

我正在学习教程中的animation自动布局 http://weblog.invasivecode.com/post/42362079291/auto-layout-and-core-animation-auto-layout-was 事情正在完善。 当我尝试在我的应用程序中使用这个概念时,试图从底部到顶部设置一个设置屏幕(UIView)的animation,当设置屏幕只是一个空的UIView时, 但是,如果我添加一个UILabel作为子视图到这个设置屏幕,animation就消失了。 在从设置屏幕删除这个UILabel时,animation是可见的。 这是我连接的网点 __weak IBOutlet UIView *settingsView; __weak IBOutlet NSLayoutConstraint *settingsBottomConstraint; __weak IBOutlet NSLayoutConstraint *settingsViewHeightConstraint; 查看没有负载设置方法(setupViews) -(void)setupViews { settingsBottomConstraint.constant = – settingsViewHeightConstraint.constant; [settingsView setNeedsUpdateConstraints]; [settingsView layoutIfNeeded]; isSettingsHidden = YES; } 隐藏/取消隐藏方法 – (IBAction)showSettingsScreen:(id)sender { if (isSettingsHidden) { settingsBottomConstraint.constant = 0; [settingsView setNeedsUpdateConstraints]; [UIView animateWithDuration:.3 animations:^{ [settingsView layoutIfNeeded]; }]; } else{ settingsBottomConstraint.constant […]

没有完成button的UIKeyboardTypeNumberPad

我们如何实现UIKeyboardTypeNumberPad,使其具有“完成”button? 默认情况下它没有。

3D从UITableViewCell触摸Peek和Pop如何将数据交给其他UIViewController?

我的应用程序在Core Data对象中存储不同的属性。 它们都显示在一个UITableView中,如果你点击一个单元格,就会显示一个DetailView。 像Master-Detail-XCode-Template一样。 现在我想用peek和pop来实现3D Touch。 就像在邮件应用程序中,3D触摸一个单元格,获得预览,按下更深,popup细节。 到目前为止,我已经得到了这个工作,但我无法弄清楚如何传递相应的数据 – (nullable UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location 和 – (void)previewingContext:(id <UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit 到另一个DetailViewController。 如果你只是点击单元格(没有3D触摸),我交出数据 – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath]; [[segue destinationViewController] setDetailItem:object]; 我正在使用一个 id detailItem 在每个ViewController中,我将相应的对象设置为它。 所以我尝试了类似的工作,所以在我的DetailViewController我的“detailItem”需要从选定的(3D触摸)单元格相应的核心数据对象。 感谢帮助 !

在UITableView后面设置渐变

我创build了一个tableViewController我调用这个函数: func setTableViewBackgroundGradient(sender: UITableViewController ,let topColor:UIColor, let bottomColor:UIColor){ let gradientBackgroundColors = [topColor.CGColor, bottomColor.CGColor] let gradientLocations = [0.0,1.0] let gradientLayer = CAGradientLayer() gradientLayer.colors = gradientBackgroundColors gradientLayer.locations = gradientLocations gradientLayer.frame = sender.tableView.bounds sender.tableView.backgroundView?.layer.insertSublayer(gradientLayer, atIndex: 0) } 有: setTableViewBackgroundGradient(self, UIColor(0xF47434), UIColor(0xEE3965)) 但我得到的是这样的:

如何在Alamofire中使用NetworkReachabilityManager

我想在Objective-C中使用类似于AFNetworkingfunction,在Swift中使用Alamofire NetworkReachabilityManager: //Reachability detection [[AFNetworkReachabilityManager sharedManager] startMonitoring]; [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { switch (status) { case AFNetworkReachabilityStatusReachableViaWWAN: { [self LoadNoInternetView:NO]; break; } case AFNetworkReachabilityStatusReachableViaWiFi: { [self LoadNoInternetView:NO]; break; } case AFNetworkReachabilityStatusNotReachable: { break; } default: { break; } } }]; 我正在使用监听器来了解networking状态的变化 let net = NetworkReachabilityManager() net?.startListening() 有人可以描述如何支持这些用例吗?

核心数据 – 默认迁移(手动)

我已经读过所有可能的博客,所以就这个问题上发表 – 但仍然不知道发生了什么事情。 我也读过这个,但仍然没有运气 – 他们的指导默认迁移种清除,但在我的情况不起作用。 我对iOS开发比较新,所以要温柔:) 这是情况:在我的应用程序(iOS)中称为报表的实体,需要进行以下更改: 数据属性 – 删除 标题属性 – 添加 reportId属性需要从整数16更改为string。 这是什么原因造成我的问题。 我从当前版本创build了我的数据模型的新版本并修改了属性。 首先这里是从应用程序的一些方法: – (NSManagedObjectModel *)managedObjectModel { if (__managedObjectModel != nil) { return __managedObjectModel; } NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"App" withExtension:@"momd"]; __managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; return __managedObjectModel; } 接着 /** Returns the persistent store coordinator for the application. […]

获取相机预览AVCaptureVideoPreviewLayer

我试图让相机input显示在预览图层视图上。 self.cameraPreviewView绑定到IB中的UIView 这是我从AV Foundation编程指南中整理出来的最新代码。 但预览从不显示 AVCaptureSession *session = [[AVCaptureSession alloc] init]; session.sessionPreset = AVCaptureSessionPresetHigh; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error = nil; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; if (!input) { NSLog(@"Couldn't create video capture device"); } [session addInput:input]; // Create video preview layer and add it to the UI AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer […]