How to call add view from NSObject class

I am working on an application where I am doing some code in a class that is derived from NSObject, and in this class I want to call another class that is a class of type UIView and add it on top of the current view or, if possible, on the window, Maybe someone will someone tell me how I will do this since I cannot call [self.view addubview: view] from a class like NSObject?

Also, I can’t switch from my current class, since here I am doing an action (loading with viewing progress), which will take time. so I have to add subview on top of my current view only from this class.

and yes, I have to remove this uiview and later when the download is complete.

Thanks in advance

+3
source share
2 answers

It looks like you want to add a view to the window:

[[UIApplication sharedApplication].keyWindow addSubView:myView];
+3
source

How to place your NSObject class inside a UIView, and then save a variable that refers to this view (for example, masterView). You can connect this in the Builder interface to a view containing NSObject, or if you are not using IB, create a UIView before creating a derived class NSObject inside it and pass a reference to the NSObject class, which points to the UIView wizard.

Then, when you want to add a new view to the screen, call

[masterView addSubview:anotherView];
0
source

Source: https://habr.com/ru/post/1769860/


All Articles