how to call add a view from NSObject class
I am working on an app where i am doing some code in a class which is derived from NSObject and in this class i want to call another class which is a UIView type class and add it above current view or if possible over window. Can someone suggest me how will i do it as i cannot call [self.view addsubview:view] from a NSObject type class?
开发者_JAVA技巧Also i can not move from my current class as here i am doing act(uploading with progress view) which will take time. so i have to add subview over my current view from this class only.
and yes i have to remove that uiview also later on when uploading completes.
Thanks in advance
Sounds like you want to add a view to the window:
[[UIApplication sharedApplication].keyWindow addSubView:myView];
How about placing your NSObject class inside a UIView, and then keeping a variable that references that view (eg masterView
). You could hook that up in Interface Builder to a view that contains the NSObject, or if you're not using IB, create a UIView before instantiating your NSObject-derived class inside it, and pass a reference to the NSObject class which points to the master UIView.
Then, when you want to add a new subview to the screen, call
[masterView addSubview:anotherView];
精彩评论