草庐IT

delegating-constructor

全部标签

ios - 从 App Delegate 呈现 View Controller

我正在尝试使用以下代码从应用程序委托(delegate)中呈现一个ViewController:-(void)interstitialViewControllerRequestSucceeded:(UIViewController*)interstitialViewController{[self.window.rootViewControllerpresentViewController:(UIViewController*)interstitialViewControlleranimated:YEScompletion:NULL];}它将在初始ViewController上显示插页

ios - 从 App Delegate 呈现 View Controller

我正在尝试使用以下代码从应用程序委托(delegate)中呈现一个ViewController:-(void)interstitialViewControllerRequestSucceeded:(UIViewController*)interstitialViewController{[self.window.rootViewControllerpresentViewController:(UIViewController*)interstitialViewControlleranimated:YEScompletion:NULL];}它将在初始ViewController上显示插页

ios - -[UIApplication delegate] 只能从主线程调用

这个警告导致了一个严重的问题,因为我真的无法使用Xcode9beta2在主线程之外调用委托(delegate)。奇怪的是,当我使用Xcode8.3.3时,它是有效的。我还认为只从主线程调用委托(delegate)是个好习惯,不是吗?那么,为什么这会导致应用程序现在崩溃? 最佳答案 就像这样从主线程调用它。objective-Cdispatch_async(dispatch_get_main_queue(),^{[[UIApplicationdelegate]fooBar];});swiftDispatchQueue.main.asy

ios - -[UIApplication delegate] 只能从主线程调用

这个警告导致了一个严重的问题,因为我真的无法使用Xcode9beta2在主线程之外调用委托(delegate)。奇怪的是,当我使用Xcode8.3.3时,它是有效的。我还认为只从主线程调用委托(delegate)是个好习惯,不是吗?那么,为什么这会导致应用程序现在崩溃? 最佳答案 就像这样从主线程调用它。objective-Cdispatch_async(dispatch_get_main_queue(),^{[[UIApplicationdelegate]fooBar];});swiftDispatchQueue.main.asy

ios - 在哪里突出显示 UICollectionViewCell : delegate or cell?

根据CollectionViewProgrammingGuide应该在UICollectionViewDelegate中处理单元格高亮显示的视觉状态。像这样:-(void)collectionView:(PSUICollectionView*)collectionViewdidHighlightItemAtIndexPath:(NSIndexPath*)indexPath{MYCollectionViewCell*cell=(MYCollectionViewCell*)[collectionViewcellForItemAtIndexPath:indexPath];[cellhighl

ios - 在哪里突出显示 UICollectionViewCell : delegate or cell?

根据CollectionViewProgrammingGuide应该在UICollectionViewDelegate中处理单元格高亮显示的视觉状态。像这样:-(void)collectionView:(PSUICollectionView*)collectionViewdidHighlightItemAtIndexPath:(NSIndexPath*)indexPath{MYCollectionViewCell*cell=(MYCollectionViewCell*)[collectionViewcellForItemAtIndexPath:indexPath];[cellhighl

ios - 在应用程序委托(delegate)中返回之前等待异步任务完成完成 block

我正在使用UIManagedDocument的子类在我的项目中使用核心数据。重点是让子类返回一个单例实例,这样我的屏幕就可以简单地调用它,并且托管对象上下文对所有这些实例都保持不变。在使用UIManagedDocument之前,如果它的文件路径已经存在,我需要通过打开它来准备它,或者如果它还不存在则创建它。我在子类中创建了一个方便的方法prepareWithCompletionHandler:来促进这两种情况。@implementationSPRManagedDocument//Singletonclassmethodhere.Then...-(void)prepareWithComp

ios - 在应用程序委托(delegate)中返回之前等待异步任务完成完成 block

我正在使用UIManagedDocument的子类在我的项目中使用核心数据。重点是让子类返回一个单例实例,这样我的屏幕就可以简单地调用它,并且托管对象上下文对所有这些实例都保持不变。在使用UIManagedDocument之前,如果它的文件路径已经存在,我需要通过打开它来准备它,或者如果它还不存在则创建它。我在子类中创建了一个方便的方法prepareWithCompletionHandler:来促进这两种情况。@implementationSPRManagedDocument//Singletonclassmethodhere.Then...-(void)prepareWithComp

iphone - NSUrlConnection 委托(delegate) - 获取 http 状态代码

在iOS中,我如何接收来自Web服务器响应的http状态代码(404,500200等)。我假设它在NSUrlConnectionDelegate中。Objective-C或Monotouch.NET可以回答。 最佳答案 是的,您可以在委托(delegate)方法-didRecieveResponse中获取状态码:-(void)connection:(NSURLConnection*)connectiondidReceiveResponse:(NSURLResponse*)response{NSHTTPURLResponse*http

iphone - NSUrlConnection 委托(delegate) - 获取 http 状态代码

在iOS中,我如何接收来自Web服务器响应的http状态代码(404,500200等)。我假设它在NSUrlConnectionDelegate中。Objective-C或Monotouch.NET可以回答。 最佳答案 是的,您可以在委托(delegate)方法-didRecieveResponse中获取状态码:-(void)connection:(NSURLConnection*)connectiondidReceiveResponse:(NSURLResponse*)response{NSHTTPURLResponse*http