iphone - Accessing self.view from a static library -


So I'm building a static library for iOS, basically I want people to make some calls like this :

  [MyStaticLibrary showview]   

And to add a subview to my static library in their current view Generally I can do something like this:

  CGRact mainframe = [[USScreen main screen] border]; UIView * mView = [[UIView alloc] initWithFrame: Mainframe]; // Add some stuff to view [self.view addSubview: mView];   

But the xcode is complaining, and correctly, that I can not see myself from the stable library because I am currently using NSObject in my stable library. Is there no way for me to reach "self.view" from my static library, so can I add a view to the application screen?

1) You can set your show view method to showViewInParentView: and give the caller the view you need.

2) You can use the [[UIApplication sharedApplication] keyWindow] addSubview: mView] to directly add to the window, make sure it is at the top.

I recommend # 2 over # 2.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -