I am creating a UIViewController which have an animation on it and I want it to be displayed while "loading" or changing views. Is there a way so I can show that view in top of the others while they're doing their business logic and when they're done call in their respectives ViewDidLoad functions, a call to "hide" this facade view?
I think you want to display loading overlay which has your own custom animation and you want to show/hide this loading overlay on top of any View or ViewController. If my understanding is correct then you can achieve this as follows:
Suppose loadingOverlay is your animation view instance.
Assign some unique Tag to this:
loadingOverlay.Tag = 1678;
This can be any number which uniquely identifies your loading overlay view from all other views from UIWindow in any ViewController.
Show:
UIWindow myKeyWindow = UIApplication.SharedApplication.KeyWindow;
myKeyWindow.AddSubView(loadingOverlay);
Hide:
var loadingOverlay = myKeyWindow.ViewWithTag(1678);
//Remove completely
loadingOverlay?.RemoveFromSuperView();
//OR
//Simply hide it
loadingOverlay?.Hidden = true;
Note: If you want to use Hidden property, then you have to make sure that you add this view into UIWindow only once.
So, ideally, anything which you want to display on top of anything,
should go into KeyWindow (UiWindow)
Hope this helps!!
Related
When creating custom views, I generally create an initialization function by overriding the init(frame) function. When creating the view in my ViewController I initialize the view by passing in the .zero frame, and then set the layout using Material's layout function.
let descView = DescriptionView(frame: .zero)
However, this makes it so that my views in my custom view are not resized. For example, when setting up a custom text view in my custom view, it does not show up because I prepare it as so:
self.layout(descriptionTextView).width(self.width).height(self.height).centerVertically().centerHorizontally()
I assume it doesn't show up because when I initialize the view, its width and height are zero. What can I do to get around this?
I need to be able to hide the navbar and tabbar when I tap on the view and show it again when tapped again. Is this possible in Monotouch?
Anything that is possible with the native platform is possible with MonoTouch.
There are dozens of ways of achieving this. Perhaps the simplest thing to do is to create your own UIViewController that will host only the information you want and calling:
var myNewController = new MyNewController ()
myNewController.View.TouchDown += delegate {
myNewController.DismissViewControllerAnimated (false);
};
PresentModalViewController (yourNewController, false);
Then your myNewController must contain some code to add the actual contents that you want to show in full screen.
This relates to a question I asked a few days ago: iOS: Setting text in nib subview from view in UITabBar/UINavigationController application
I need to put the search bar and buttons on the top right of a navigation controller, this is more than the standard single button that UINavigationController.navigationItem.rightBarButtonItem allows so I am using the initWithCustomView: method of UIBarButtonItem to load a view from a nib file.
In my particular case, i've put the view as a seperate item in the main view file for that form
The problem i've got is load and display sequence and I wanted to know if this was the right approach to this?
It seems that the following happens:
viewDidLoad on my main window gets called
viewDidAppear on my main window gets called and I set up rightBarButtonItem
I then want to populate a text field on that search bar but because the loading of the view for the button item happens in the main thread, I don't know when it's appeared.
Would I be better to create a new class with nib for the search bar and buttons which would then have a viewDidLoad/viewDidAppear and I could then create a delegate function so I could 'deQueue' the text to go into the search bar?
Or, am I missing something really simple?
in the main view controller i have a scrollview and paging control.
i have added another viewcontroller's view as a page of paging control in scrollview.
now i have 9 buttons on that view controller's view which is inside scroll view.
now when i click on the buton i wants that main view controller's view should be pushed to another view controller.
but not getting how it can be done as the buttons are in view which is in the scrollview.
When a user interface element created in interface builder seems not to be doing what you told it to do, you should verify that:
you saved your changes to the nib in IB
that you correctly declared your ivars/properties as IBOutlet and connected your outlets in IB
that there are no views hijacking your events.
If the buttons in your view inside the scroll view don't appear to be getting press events, you may need to adjust the userInteractionEnabled property of parent views.
You can "move" any view from one view hierarchy to another by doing:
[myView removeFromSuperview];
[anotherParentView addSubview:myView];
I have a simple maps app with multiple pins on a map view. My intention is to tap a pin, show a callout with an accessory view, push to a Detail View Controller where you can edit that pin/locations details. This all works fine, but once i pop the Detail View Controller the callout on the map view is still there, which i want, but it still has the old uneditied values. How can i refresh/update the callout view once the Detail View Controller is popped?
I am using Core Data with a simple database. I have tried using controllerdidchangecontent, Map View Controller Will Display methods etc but my main problem is identifying which object has been added/updated/deleted and which is the corresponding callout/selected pin.
Any help appreciated...
Not sure if you had find your answer but the way to do it is to extend MKAnnotation class and creating custom annotation and passing them while creating placemarks. Later you can get them from MKAnnotationView's annotation property.
See a good implementation here
http://www.slideshare.net/360conferences/getting-oriented-with-mapkit-everything-you-need-to-get-started-with-the-new-mapping-framework
The only way I could find to update the callout info was to mess directly with the subviews of the callout.
The callout view is the first subview of the annotation view.
In the following example, I update the subtitle.The title label is the 6th and the subtitle is the 7th subview of the callout:
if (myAnnotationView.subviews.count > 0)
((UILabel*)[((UIView*)[myAnnotationView.subviews objectAtIndex:0]).subviews objectAtIndex:7]).text = #"Some example";