In the current project,I am using an UIViewController with 2 text Fields and a text area.
Text fields are used as drop-down (custom logic) and based on drop-down selection information is displayed in text area for e.g. State and city are two drop down. On click of State drop down city data is populated in second drop down and on selection of city corresponding info is fetch and displayed in Text-area.
I have a requirement to move this logic to custom popup. Can anyone guide me how to achieve this with minimal changes in Xamarin iOS.
It would use UIPopoverController in this care. You already have a view controller with all the UI elements. You can use it as the DetailViewController so you don't have to change that much. Only it's size and the background. You can use it for both iPhones and iPads.
Here you have a sample project with source code:
https://developer.xamarin.com/samples/monotouch/Popovers/
Create a new UIViewcontroller in the storyboard, set the background colour of the main view to transparent, then create another view on top of that and put in any controls you want to display etc. then in the UIViewcontrollers init method add in the following:
public OverlayView(IntPtr handle) : base (handle)
{
ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
}
That way the background view that you've set as transparent won't just show black, it'll show in the context of the screen that called it, then you just present it as you would any other view, and add in some dismiss action events if you want it to pass data back etc. Hope this helps.
Related
I have a View Controller that is presented when you first open the app, and I have another controller that can be shown on screen if you tap a button at the top of the screen. However, instead of doing it this way I was wondering if I can either drag the view down or tap the button and have an animation take care of that.
I have tried doing this with a PageView Controller, but this doesn't show the effect I wanted as it simply translates over to the next view and doesn't actually keep the initial view fixed in place while the second view slides over it.
Also, instead of a view controller would a view initially placed out of bounds in the main View Controller work? Thanks in advance!
You could use a side menu like MMDrawerController that has 4 type of animations for presenting the viewController.
Or you can create your custom UIView (not viewController) even using Interface Builder and animate that screen yourself. The animation can be started using UIScreenEdgePanGestureRecognizer.
Is it possible to do navigation within the same window in a mac application ?(Like it is possible in ios apps).I want to show each view in the same window instead of opening different windows on a button click.
e.g When a user clicks a button then the next page should be loaded in the same window.(The next page will have nothing in common with the current page.)
You may use Tab View for easy switching between views on a same window.
UPDATE:
You may also customize your tab view , make it tabless (In the attributes inspector set style to tabless) and use your buttons to switch between views.
You may take help from the following link : http://devcry.heiho.net/2012/01/nstabview-tutorial.html
OR
You may add or remove subviews from your window on button clicks, using
[[yourWindow contentView] addSubview: yourSubview]; // Add subview to window
[yourSubview removeFromSuperview]; //Remove subview
UPDATE:
Steps to swap between views using a tabless tab view.
Drag a NSTabView to your xib.
Set the no. of tabs in attribute inspector to no. of views you want.
Design each view of the tab as per your requirement.
Now in the attribute inspector of tabview, set style to tabless.
Now drag the buttons you want to use for swapping between views. Suppose Button0 and Button1 are for 1st and 2nd view of your tab view.
Create a IBOutlet for your NSTabView in your .h file. Bind it to the referencing outlet of you tabview.
IBOutLet NSTabView* tabview;
Set a IBAction for both your buttons in your .h class file.
In the button action method for button1, use
- (IBAction)button1clicked:(id)sender
{
[tab selectTabViewItemAtIndex:0];
}
Similarly in button2 action method use:
[tab selectTabViewItemAtIndex:1];
In this way you can have any no. of views and you may select any view on button click using
[tab selectTabViewItemAtIndex:(index of the view you want to load)];
In general you want to google for view swapping.
There are tons of examples out there. Some from Apple and lots elsewhere.
Much of it is very similar to iOS.
You need to read the docs a bit too.
Understand NSView and how to load views from nibs, how to create view objects in code, how to add a subview and how to remove a view.
There are many approaches to having different views for different reasons. The right approach is a combination of style, experience and what your app actually needs to do.
Cocoa includes NSBox, NSTabView, and lots of others. Those two can be configured to not display any visual indication that they are containers.
You will also need to understand at least a little about NSWindow to understand its content view (the root container of other views generally)
I have a reasonably complicated UIView which contains several nested views which are displayed according to a variety of responses - all are laid out in a storyboard.
Is there a way to hide a view in the foreground to work on a view in the background? As its really fiddly selecting particular elements to arrange / style!?
I've been trying to figure out a nice way to do this, some function like hiding the view and its subviews from the storyboard (not from the actual application), but couldn't find anything.
This is not the nicest of ways but it is how I do it at the moment...
What I do is select the views I want to "hide" from the document outline and add a constant (screen width/height) value to its x/y origin value to push them out of the screen. I also change the document label for those views (Identity Inspector > Document > Label) to something like "Hidden" so I can later search for the "hidden" views from the document outline and put them back where they belong.
I have 2 work arounds.
A) Change the View Controllers size to freeform. Set its size to be really large so I can space out the views.
B) Use the sort order of the views Document Outline (lowest is front most) and add an image view (same as the view background) under the first view to block the others. Then delete it after finishing my edits.
or xcode developers could just simple add a design-visible checkbox for views and controls.... but ill take my rants somewhere else.
In xcode 7 you can do it from the storybord
for more details
https://stackoverflow.com/a/25213491/4879683
Maybe this could help you :
Open your storyboard in the Finder and edit it with a simple text editor (not xcode).
You will see it's just a xml file.Look for the view you want to hide, and add hidden="YES" in the parameters list.
That's what I do on my own project.
In Xcode when you select your storyboard, you have a panel that displays all your view controllers and their hierarchy. If you change the order of the elements you change the background/foreground order.
You can add extra views to the scene dock.
These views get initiated along with the view controller, but are not added to the view controller's view hierarchy. You can reference them using IBOutlets.
e.g. I have a full screen loading view that I added to the scene dock instead of covering up the view controller in the storyboard. I can add the loading view to the view controller's view hierarchy in code:
#IBOutlet weak var loadingView: UIView!
...
loadingView.frame = view.bounds
loadingView.autoresizingMask = UIViewAutoresizing.FlexibleWidth.union(UIViewAutoresizing.FlexibleHeight)
view.addSubview(loadingView)
Reference: https://developer.apple.com/library/ios/recipes/xcode_help-IB_storyboard/Chapters/AddViewsToDock.html
I'm new in XCode and still learning XCode (currently using Xcode 4.5.2).
Based on Apple tutorial about IconCollection, i try to make a kind of thumbnail view app with ImageMetada fields Stored in an array as the CollectionView Datasource.
here are some basic information :
1 xib file (MainMenu.xib)
1 window with a CollectionView and TableView on the main view.
1 object controller delegating the window and aplication with Custom class Name : ThumbsViewController
1 Custom view for collection item placed on the xib (but not on main window or its subviews) consists of 1 ImageView, 1 Label (textfield) and 2 Button. This view use custom class : ThumbViewItem. First Button used to set the Date info and second button to remove it. My purpose is when i put mouse on current item, the first button should enabled only if no date info found on metadata and the second button should enabled only if date info found on metadata. I've set the iboutlet for each to ThumbViewItem.h file (imgpic, imglabel, imgbtn1, and imgbtn2). This idea maybe a little bit looks like thumbnail view of photo collection at the bottom of Adobe lightroom 4.
NsCollectionViewItem with it's view outlet connected to ThumbViewItem(4) and it's itemPrototype outlet connected to CollectionView on the window(2)
An Array (imageInfos) to Image Info including pic and metadata defined on ThumbsViewController.h(3). I vad plan to use this array as shared array for used in collectionview and tableview
Data Stored in array is an interface caled imageinfo defined in imageinfo.h. I've put thumbnail pic and metadata dictionary on it.
Table could display info stored in array including filename, path, and metadata (Date and GPS information) correctly. But the CollectionItem's custom view wont.
No image, no name, no information.
On debugging, i found that each of IBOutlet : imgpic, imglabel, imgbtn1, and imgbtn2 is null.
Why all IBOutlet properties/links didn't work ?
Is there something i forgot?
How to get the imageinfo stored in imageinfos array from custom view associated to collectionitem for custom draw purpose?
CollectionView ---> Collection Item ---> custom view
for example while perform custom draw on a customview associated to a collectionitem at index number 4, how could i get that index (number 4)?
My code to get the index is get its superview as collectionview and get its index on superview's subviews as follow :
-(NSInteger) getIndexInCollection
{
return [[[self superview] subviews] indexOfObject:self];
}
The problems with this code is sometimes it works sometimes it doesn't.
Any help would be appreciated. Thanks.
read the document about the NSCollectionview, IconViewPrototype.xib be careful the simple code use some bindings, In Collection.xib should make sure how to use IconViewPrototype.xib to show Custom view,and make sure how to get the datasoure according bindings.
My app is based on a navigation controller that contains a a custom view controller which embed two view controllers.
The first one is an UICollectionViewController for which I have designed the cell via IB.
Cell contains an imageview and a label.
On the execution the app shows correctly all the cells with their images and related labels, but only some of them trigger the DidSelect event when you touch them.
I have tried to change the cell position on the screen changing the interspace setting within IB, and in this way some of the cells that before were "insensitive" now are sensitive and vice versa.
I have also checked that both image and label are user interactive.
Any suggestions?
Many thanks
I made a simple mistake: in the container view I inserted two views, the view containing the UICollectionViewController is below the other, whose content, most of the time, is hidden, but I set hidden the view contained not this specific one.