草庐IT

AT_appDelegate

全部标签

ios - 为什么我每次需要使用它时都必须实例化 appdelegate?

目前,当我需要应用程序委托(delegate)的本地方法级实例时,我使用此代码:AppDelegate*appDelegate=(AppDelegate*)[[UIApplicationsharedApplication]delegate];是否有某种更简单的“全局”方式来访问它?在C#等其他语言中,您可以创建公共(public)静态类,只需说...if(ObjectHelper.isLoggedin){//DoWork}但是当我想使用appdelegate时,我发现在objective-c中有点令人沮丧,我必须:在header中导入,实例化它的本地实例,实际得到一个我需要它的全局状态

iphone - 'Appdelegate' 没有可见的@interface 声明选择器 'setupTabBarController'

我在Appdelegate.m中创建了一个方法-(void)setupTabBarController{//detailsgoeshere}现在在ABC.m中,我想访问setupTabBarController我已经包含了应用委托(delegate):#import"AppDelegate.h"然后:AppDelegate*maindelegate=[[AppDelegatealloc]init];[maindelegatesetupTabBarController];但是显示错误,Novisible@interfacefor'Appdelegate'declarestheselect

ios - 无法创建 Podfile,因为 'plist file at path doesn' 不存在”

运行命令podinit.返回:[!]Theplistfileatpath/Users/admin/Desktop/TestProject/project.pbxprojdoesn'texist.我正在从“测试项目”文件夹运行命令。要获取.plist文件:TestProject>TestProject>Info.plist。我在build设置中设置了plist文件的路径,如下所示:我错过了什么? 最佳答案 因为命令不是podinit.它是podinitCocaoPodsGuidePage那个句点正好是cocoapod的guide中的那

iphone - 使用未声明的标识符 'AppDelegate'

为什么使用此代码会收到此错误消息?“使用未声明的标识符‘AppDelegate’intmain(intargc,char*argv[]){@autoreleasepool{returnUIApplicationMain(argc,argv,nil,NSStringFromClass([AppDelegateclass]));}} 最佳答案 您是否导入了应用委托(delegate)?#import"AppDelegate.h" 关于iphone-使用未声明的标识符'AppDelegate'

ios - 如何强制-drawViewHierarchyInRect :afterScreenUpdates: to take snapshots at @2x resolution?

-drawViewHierarchyInRect:afterScreenUpdates:是fastway在iOS7中拍摄View层次结构的快照。它拍摄快照,但分辨率为@1x。这些快照在iPhone5S上看起来像素化且模糊。我从中创建快照的View未转换。我不想模糊它,想要在屏幕上看到的高质量。以下是我如何捕获它:UIGraphicsBeginImageContext(self.bounds.size);[selfdrawViewHierarchyInRect:self.boundsafterScreenUpdates:YES];UIImage*image=UIGraphicsGetIm

ios - @IBInspectable : wrong bounds and frames at runtime when I add subviews

这是我的@IBInspectable:代码:@IBDesignableclassPBOView:UIView{@IBInspectablevarborderRightColor:UIColor?{didSet{letborderRightView=UIView(frame:CGRectMake(frame.size.width-10,0,10,frame.size.height))borderRightView.backgroundColor=borderRightColoraddSubview(borderRightView)}}}这是Storyboard中的结果:UIView的宽度

iphone - 从 UIViewController 到 Appdelegate 的导航

我正在尝试通过单击按钮从UIViewController类(名称为CartViewController)导航到Appdelegate(名称为SimpleDemoAppDelegate)。按钮上IBAction的方法和代码是-(IBAction)Go{AppDelegate*appDelegate=(AppDelegate*)[UIApplicationsharedApplication].delegate;UIViewController*presentingViewController=appDelegate.viewController;}我也试过-(IBAction)Go{Sim

objective-c - AppDelegate 未找到 ViewController 的声明和合成属性

我的应用程序已经开发了几个月,现在被要求添加核心数据。SMH。这是一个tabViewController应用程序。我不知道这是否有助于回答。所以我在这里尝试添加它,但出现错误。我在AppDelegate.h中构建核心数据,因此我创建了这些IVAR并稍后在.m中适本地构建它们。@property(readonly,strong,nonatomic)NSManagedObjectContext*managedObjectContext;@property(readonly,strong,nonatomic)NSManagedObjectModel*managedObjectModel;@p

ios - AppDelegate window.rootViewController 属性

我的iOS应用程序有问题。它基于Storyboard。因此,要设置rootViewController属性,将InterfaceBuilder中的“InitialViewController”属性和项目设置中的MainInterface-Property设置为我的Storyboard的名称就足够了。我仍然总是收到消息“应用程序窗口应该在应用程序启动结束时有一个RootViewController”。我在applicationDidFinishLaunching部分做了几件事,但即使除了返回YES之外的所有内容;被注释掉了,我收到了消息。我该如何解决这个警告?或者我可以在一切正常时忽略它

ios - 类扩展 'AppDelegate' 中属性的非法重新声明(属性必须是 'readwrite' ,而它的主要属性必须是 'readonly' )

我移动了这一行:@property(nonatomic,retain)IBOutletUIWindow*window;进入我的AppDelegate中的类扩展,但现在出现此错误:Illegalredeclarationofpropertyinclassextension'AppDelegate'(attributemustbe'readwrite',whileitsprimarymustbe'readonly').m文件中的完整代码如下所示:@interfaceAppDelegate()@property(nonatomic,retain)IBOutletUIWindow*window