I have graphic that I would like to create as a UIAlertController? Can I create a xib and then call that file to present it? What is the best way to do this?
An alert is nothing but a presented view controller. So make your own view controller and call present. It's as simple as that.
You can create a subclass of UIView and its corresponding Xib.
Just create an instance whenever you need to use it and just add it as a subview.
And on the tap of close button just remove it.
Make sure that you create a method in the UIView subclass, which accepts the text, and the button titles, and call the method whenever you are adding it.
So you can add dynamic button titles or texts if the same popup is being used in multiple places in your application.
Related
I have a table view with one custom cell that I have already built and hooked up. When the user taps the add cell button I want it to add a different custom cell. I don't know where to start this process. Do I build it on the storyboard then hide it? Or what is the best means?
You should create all of your custom cells in the storyboard, and then implement UITableViewDataSource methods, where you return whatever cells you want.
Check out the documentation
This is maybe a simple question, but I don't have a clue the keyword i had to search for this...
I want to create a simple selector (I called it spinner in Android). This is what i want to achieve
Or it will take a whole screen if it's in ipod touch / iphone.
So, I have 3 button that represent filter (category, country, sort) for a ListView... and if I press one of the button, a popover / dialog should be appear to select the filter for each button.
thanks...
Please let me know if I need to add some information to make the question clear.
Its not so much typical that is it appearing.
Create a new UIViewController class with xib and adjust view size you want to display for combo box or popviewControoler. Then put navigation controller over and tableviewController.
And customize your UIViewController using its controller class. Controller class will be reponsible for displaying and selecting data.
Now in your MainViewController From where you want to show ComboBox or popviewcontroller.
declare popViewController instance variable,synthesize it.
implement a userdefined method here alloc your popviewcontroller class and assign it to popviewController instance variable of your class.
Then called it didSelectRowAtIndexPath.
When popover dismiss you set popViewController result in instance variable of this class so it can easily access in MainViewController class.
You can achieve combo box like functionality by adding a UItableView in a UIView and implement all the delegates of UITableView in that custom view.
Now you can add object of that custom UIView where ever you want that combo. Just you have to workout with some Frame setting.
I used to create the UI thru code. But now I have to use storyboard. I am confused about how to add the event handlers to the controls added on the storyboard and how to bind the data dynamically to the controls added on storyboard. A sample scenario is An UIView is added on the storyboard and two UITableViews and a button are added on top of it. I want to add event handler to the button and bind data to the table views. How do I do this. If I subclass the UIView added on the storyboard will I have access to the controls(button, two table views) added on top of the view or how else I should achieve this ?. Please help !
Adding an event handler to a button is relatively simple. In your UIViewController subclass simply add a method similar to the one below, then in your interface builder select the viewcontroller and on the right side panel click the right most button at the top which looks like an arrow pointing to the right. under received actions drag the circle to the button that you want to perform the action.
-(IBAction)doSomething:(id)sender{
//code for doing what you want your button to do.
}
A separate way you could do it, if you still want to do it programatically is to do the same thing you're used to doing, except in your .h file add IBOutlet UIButton *buttonName; and in the right pane under outlets you'll see your button. which can then be referenced by name within the .m file.
I want to implement a drop-down list in an iPhone application, the same like you might have seen in iBooks when you select PDFs/Books.
I have a slight idea how to implement it, just correct me if I am wrong:
Create the button
On a click event of the button define a CGRect and within the CGRect draw a LoadTableView
Load TableViewData at runtime.
Is that correct? If not, how should I do it?
Here's a much better/easier way to do it.
Create custom UITableViewController and associated nib. Use this class to encapsulate your tableView and data.
When the user clicks on your button, instantiate your custom view controller and display it modally using presentModalViewController:animated
When the user has selected an option from your popup view, call back to the parent view with the results.
Dismiss your table view with dismissModalViewControllerAnimated:
This is what iBooks does with a highly customized UITableViewController.
Are you looking for a UIPickerView?
This component gives you the possibility of selecting from a custom number of elements through a dedicate table view. Use it in conjunction with a UIActionSheet to get the best results.
I have a UIScrollView.
In there I add buttons programmatically.
Right now I just use UIButton and set one title. But I need to have an UIImage View in there, that will change upon certain events, Text that will change too etc. and I would like to style that in Interface Builder, but I can't figure out how to do this. Which class should I extend, and what kind of xib should I create and what in there, so that in the end I can make the right connections and so that I can listen for UIControlEventTouchDown of that Button.
Just make a UIViewController subclass with a nib. You can do everything you want from there.