I have a main view with a UINavigationController and a subview (both added through interface builder). I have a UIBarButtonItem in the navigation toolbar. When that button is clicked, I want a popover view to come up (with a table format) with options for different subviews to choose from. When a user chooses one of the subviews (by clicking a cell), the popover should fade away and the subview should change to the user's chosen view.
Those view options should be loaded from separate xib files.
I know it's a relatively complicated question, but what is the best way to do this?
I don't necessarily need code, but that would be helpful. Thanks guys!
Check this tutorial about the popOvers:
http://mobiforge.com/designing/story/using-popoverview-ipad-app-development
Are you looking for something similar to this?
Checkout the – loadNibNamed:owner:options: of NSBundle(UINibLoadingAdditions). Your view will be the first index object of the returned array commonly.
Related
I am looking at Apple's Date Cell (Date Cell Link) example project and I have a question about the Scene Dock in MyTableViewController. How come there are items extra items in the scene (Like Picker and Done) that are next to First Responder, Exit, and My Table View Controller? How can this be done? Also, how is this helpful?
This image shows the Scene Dock that I am referring to. Don't mind the titles, I renamed the project.
This image shows the Scene Outline for MyTableViewController, where the Picker and Done Button are shown next to the My Table View Controller, First Responder, and Exit and not within My Table View Controller.
This image shows an expanded outline for My Table View Controller where the Picker object is found also. But not Done Button is nowhere to be found inside My Table View Controller.
This image shows the code to connect to Picker and Done Button There is nothing special to this.
When I delete UIDatePicker in the scene of the controller (not in the cell), the inline DatePicker still works.
I think this sample is meant to support iOS 6.1 or earlier, to reveal the UIDatePicker as an external slide-in view, so it needs to be in the controller for IBOutlet connection.
Hope this will help.
Normally, the MyTableViewController should not be of type UITableViewController but its superclass UIViewController. This is normally necessary because UITableViewController has by definition its main view property set to the table view. It is then difficult to place other views into this view.
With a UIViewController, however, you can add any number of views. This is necessary in this case to accommodate the button and picker. The table view controller functionality can still be achieved by manually adding the UITableViewDataSource and UITableViewDelegate protocols and overriding the appropriate methods.
However, Apple here shows that it is possible by placing the other views on the same level as the main view, the table view. This is admittedly quite confusing. I usually prefer adding non-standard views as subviews to the view of a plain UIViewController.
You can drag things like picker views from the library to the scene dock to add them there.
As to the utility of doing this, I have no idea what that would be.
In this case I think that the picker and done button are left over from the writers of the code experimenting with ideas and forgetting to delete them. To verify that just delete the picker view and done button and see if everything still works.
I have a view controller(A) which shows a list of items download from server.
I have another view controller(B) with segmented control.
When second index of segmentedControl is selected, the view controller(B) shows a list of items in the same format as in the controller(A).
When first index of segmentedControl is selected, the view controller(B) shows the items in different format.
I want A and B share a code for the common stuff.
I first thought ok I could move all the view-related code to "common_view class" and use the view class from both controllers.
But, it turns out that there are codes which are not related to view(such as downloading stuff from server, which is controller-part of mvc pattern).
Now I'm perplexed, "is it a good idea to share a controller-part code? is it even possible?"
I could factor out a common code into a commonViewController, and instantiate it from controller(A) and controller(B), and add commonViewController.view as a subview.
But is this really desirable? or do you suggest any better way to do this?
Yes definitely..you can.Use two NIBS in this case.The first NIB wil be used by ViewController A and first segment of ViewController B.On selection of second segment in ViewController B addSubView of viewControllerA which initsWithSecondNiB name.Once you have added them ,control their visibility by show/hide when toggling between between the two segments of viewcontrollerB
I have a view controller with user content like text/images/location data and i would like to duplicate the viewController and present it modally (presentModalViewController) when the user taps the edit button. The reason for doing this is because i want it to be clear that the user is entering the edit mode by using the transition/animation that comes with a modally presented controller.
Does anybody knows how to duplicate an entire viewController + its view? i don't want the overhead of reallocating the entire viewController. I tried a couple of things, but i haven't had any luck.
Any help/information would be welcome.
That sounds a little impractical. You could make an image of the current screen contents, present that using whatever animation you like on top of everything, and then remove it?
Or make other changes to your view (rearrangement of views, appearance of other controls, changes of colour) in your viewController's setEditing:animated: method.
I've been looking everywhere but can't seem to find any examples/tutorials for my situation (not sure how to google it..)
So i have a window where a portion of it should be static (buttons and such) and there is a dynamic part (bottom leftish) that should change subviews.
So what i'm looking for is a way so that clicking the buttons in the static area will change the dynamic area to a view of my choice. I have no idea how to do this using the IB, but doing it programatically seems the only way. Any suggestions(I do not want to use a tab bar controller)?
Oh, and is there a benefit to making views and such programatically vs through the IB?
Thanks!
You can also achieve it programatically. Just create another viewcontroller class (as many as u want). In the loadView method of it create a UIView in the coordinates where u want to add the subview in the current view. Now create an instance of this viewcontroller class in the currentview controller and add it as a subview. You will get the subview at the desired location.If u want to change it dynamically create as many views and then add them to the array and change them whenever the button is clicked.
Hope this helps.
You should perform the switch in your view controller. The static buttons can have their actions hooked up to that controller (in IB), which can have an outlet (in IB) to the subviews and perform the swap.
As for when you should use IB, see this question.
You can do it from interface builder as well. You just need to take viewController from interface builder drag-n-drop to main window. assign IBAction to all buttons to add different viewController's view to main window just make their frame some smaller.
if u want to change or views by click on button then u chose segmentcontrol switch. and cod for each segment like as when click on segment 0 then open first sub view and when click on segment1 then open second sub view. And make by default unselected so that ur static view will appear initially lunching of view.
I have a UINavigationController App. I want to add a small bar just below the UINavigationBar, around 20px height. y application is almost finished, so I want to rebuild as less code as possible. For example, if I wanted to add a button in the bottom of every view of my application, I can do that by extending UIViewController with a category, and adding a UIButton as a subview of the current controller view, maybe in the viewDidLoad method.
This approach works fine, and so I can add my UILabel to all my views at the top of them. The problem is that it does not TAKE SPACE. It is always on top of my previous views (UITableView...). What is the best way (or just one way) to accomplish such a thing without having to create for example a view with 2 frames, and having all my main views extending it?
I thought of changing UINavigationBar height, but that is definitely not an option.The prompt property of UINabivationBar is just to big (around 30px).
I also tried to create a new view in the viewWillAppear method of every UIViewController, adding to that view my breadcrumb subview, and the original view, but it is not working.
Any ideas on this?
Thank you!
If I were you, I'd make a new UIView subclass to represent this thing, and embed it on the views of the individual UIViewControllers. They can get at the navigation stack by looking at the UINavigationController's .navigationControllers array, walk that and get view titles, etc.