I have a app that starts with a empty UITableViewController, which is pretty .. well, emtpy. Now I was wondering if I could hint the user by painting something else on the view, like pointing an arrow to the plus button and say something like "press here to add something new"
I'll guess I have to do this in the viewDidLoad method, where I also init my NSFetchedResultsController, so I actually know if there are any objects in my list. I never put controls on the screen by code so I am not sure where to start and where to put em on. will that be the [self view] ?
Thanks
You could either try [tableview addSubview:xyz] or add it to the UITableViewController holding viewcontroller or you could (iphonestyle) add an add button to the NavigationBar.
I wouldn't direct the user to "press" anything, ever, on iOS. Use "tap" instead.
If you're using standard UI, you'll probably have a button that looks like [+], which is consistent enough across iPhone apps that your prompt should be unnecessary.
If you still want to add your prompt, I would subclass a UIViewController, implement the UITableViewDelegate and UITableViewDataSource protocols, and add a the prompt (which itself will be a subclass of UIView) to the view hierarchy of the controller.
Related
I'm trying to execute code when a button is pressed for an application but I can't find how to change the views after the code is executed. Is there a way to switch views how I want to or is there another way? Thank you in advanced, I'm very new to xcode.
edit: I'm trying to go from one view to another, not the view controller and yes I have one storyboard that I planned on using for the whole project if possible.
To execute code when a button is pressed, you have to set up a method that the button is hooked into. Because you said you're using storyboards, I'll assume your button is on the storyboard. Go to the assistant editor, hold ctrl, and click-and-drag from the button to the view controller's .m file (#implementation section). This will create an IBAction method, and any code in this method will execute whenever you press the button.
The method will look like this:
- (IBAction)aButtonPress:(id)sender {
}
According to your comments, you say you only want to change the on-screen view, and not transition from one view to the next.
Views are added and removed with the following methods:
[aSuperview addSubview:aSubview];
[aSubview removeFromSuperview];
I can't really tell you much else with a lot more detail from you... and even though I asked twice in the comments and you said you only want to change the view, not the view controller... I think you probably need to transition to a new view controller. Impossible to know for sure as you've given almost no detail...
But if you want to transition between view controllers (which also transitions views), then ...
Create two view controllers on the storyboard. Hook them together with a segue, and give that segue a name. Now, to perform that segue in code:
[self performSegueWithIdentifier:#"YOUR_SEGUE_NAME" sender:self];
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.
Basically i wanted to implement a popup UIView so i followed what was posted here
POP-UP UIView "IMDB App" style
This works very well. However i have one query. My main view is a tableView. so when a view is popped up i disable scrolling in the table. Now when the popup subView is removed, i need to re-enable scrolling. How do i achieve that? i can't use willRemoveFromSuperview because the popup view is loading a different NIB altogether.
Should i use Notifications?
hope i was clear with explaining the scenario.
Thanks in advance!
Feloneous Cat has the correct answer. This is the perfect use a #protocol in your popup view along with a registered delegate. Something is triggering that popup view to close. Whatever that trigger is, call the protocol and the delegate can handle the situation as needed.
Furthermore, when protocols are used correctly, your code becomes very reusable within a project as well as in other projects.
What you could do is subclass UIView and override removeFromSuperview to send a notification. I don't think there's ever a case where a view gets removed without using the removeFromSuperview method.
How can I make an iphone application that uses a UITableView but so the it won't ocupy all the screen?
I want to put below some buttons that will have the role of tabs so when i press one, a different UIView(UiTableVIew) will show above.
I know I have to extend somehow the class and modify it's apearance but it can't find an example so that the table is not the main view
I have something like this
View
-TableView
-UIImage (as background)
-button1
-button2
-button3
-button4
-button5 (will use this as a badge)
here's an example
screen shot for the layout
I know it's not very standard, usualy you do this with the upper part bar..
but it's the way I have to make it so it has been chosen...
Thank you guys
Easy:
1) don' use a UITableViewController, use a subclass of UIViewController
2) in your xib file (or your code), set the frame of the UITableView however you like
3) don't forget to have your UIViewController class confom to UITableViewDataSource and UITableViewDelegate protocols, and to set your UIViewController as the delegate of the UITableView object.
I have a UIViewController that is a UITextFieldDelegate, and I would like the keyboard for its text field to appear as soon as the user navigates to this view, without having to actually touch the text field. It would also be nice to be able to "dismiss" the entire view when the keyboard is dismissed. I am loading the view from a xib file.
I don't have an ivar in the code for the UITextField as yet. I would guess I need one. At this point I am just relying on the delegate to pop up the keyboard.
(I know its not a UITextViewDelegate, like the tag says, but I am new to stackoverflow and can't create the correct UITextFieldDelegate tag.)
Sounds like you want to use [textField becomeFirstResponder] in viewDidAppear.