I am very new to IOS development and Objective-C as i have just come from a mostly Java background. I have quite frankly searched everywhere on the web to find the answer to my question but nobody as it seems can give a clear concise answer on how to do this so anything would be VERY much appreciated!
So here is what i am trying to do. I have a UITableView and a UIToolBar below it with a UIBarButtonItem. What i want to do is be able to press the BarButtonItem and then have a new TableViewCell with a text field in it be created and placed at the top of the TableView that has a unique tag so that i can parse through the text fields later and retrieve the text to store into a mutable array.
Any help would be really awesome so thank you in advance, i would really like to get this working! If you have any questions on the code i have or more details on what i am asking please ask away!
Well there are plenty of resources on how to add TableViews, Toolbars, etc... Here's an overview of what you'll want to do.
In your ViewController's view, add a UITableView to it, but remember you want to leave space in your ViewController's view for the toolbar at the bottom of the screen. So set the tableView.frame accordingly.
Look up how to add a UIToolbar (http://stackoverflow.com/a/7712240/1457445 is a good start)
Then how to add a UIBarButtonItem (http://stackoverflow.com/questions/5383906/how-to-add-uibarbuttonitem-in-uitoolbar-in-code)
As for adding the textView in the UITableViewCell, you simply call [tableView.contentView addSubview:yourTextView];
Again, there is plenty of help out there for customizing UITableViewCells (http://stackoverflow.com/questions/4238760/how-to-make-a-uitableviewcell-with-a-uitextview-inside-that-dynamically-adjust)
And to top it off, you'll need to figure out how to add the textview cell to the table - another great SO post (http://stackoverflow.com/questions/5824998/uitableview-adding-cells-dynamically)
The simplest way is put your UITextField on UITableView header when UIToolbar button item touched. The simplest way is put your UITextField on UITableView header when UIToolbar button item touched. After user done on UITextField then update your NSMutableArray reload data of UITableView and remove header on UITableView.
Related
I have UITableView in a ViewController (not a UITableViewController) with UITextFields in each row. I would like the TableView to automatically scroll so that the row below the row being edited is always displayed. This allows the user to tap the next row to edit it. The built in iOS Reminders app has this behaviour.
I have followed Apple's advice on managing the keyboard but that only scrolls to show the row you are editing just above the keyboard, not the row below it.
I have tried adjusting the frame in scrollRectToVisible: but it makes no difference. In fact commenting out that line of code seems to have no effect at all.
It seems that the UITableView will always try to scroll to show the UITextfield being edited just above the keyboard, and I can't find a way of adjusting or overriding this behaviour so that it shows the row below it also.
Update:
I've found that the automatic scrolling behaviour can be prevented by overriding the private scrollTextFieldToVisible method of UITextField.
However, the automatic scrolling code provided by Apple in the linked documentation still does not work.
You can try setting setContentOffset property instead of scrollRectToVisible. like
[self->_scrollView setContentOffset:CGPointMake(0, textFieldRect.origin.y)];
Please follow the below link, it will make your work very easy.
Just add the files and make the tableview class name as "TPKeyboardAvoidingTableView"
https://github.com/michaeltyson/TPKeyboardAvoiding
I can't find anything else on the internet about this specific topic. Everyone else wants to know how to do inline UIPickerView, but there is nothing on just having a UIPickerView appear over a table.
I have a TableView with a bunch of populated cells. I also have a defunct button in the top left of the screen. What I want is to be able to press the button, bring up a Picker and sort the TableView's cells based on what is selected.
I've been looking around and trying for ages and I just can't find anything detailing a solution to my problem.
I would try using ActionSheetPicker-3.0
It makes it easy to present a UIPickerView over your current view without having to use a delegate as it uses callback blocks.
I have tried both ways below to place SearchBar on UITableView.
TabBarController > UITableViewController(Put SearchBar)
TabBarController > UIViewController > UITableViewController(Put SearchBar)
When I try the second way, then it doesn't work.
(SearchBar cannot show on UITableViewController)
Can anyone tell me what happend?
Here is my xcode project file:
http://www2.zshares.net/tg14vowqzvaw
the usual way to do this would be to put the saerch bar in the header-section of the uitableview its supposed to search. you can do this using the
-tableview: viewForHeaderInSection:
method from the UITableViewDelegate-Protocol. his works in both TableViewControllers and regular ViewControllers that just have a TableView on them. see the mail app on the iphone for an example of this.
if you really NEED the search bar to be outside of the tableview, then you will have to use a regular view controller and just place the search bar in a view above/under the tableView.
other than that, i dont know what to tell you. And what is a TabbedViewController? Do you mean TabBarController? What does that have to do with search bars? Im kinda lacking the time to go through your project, so if you rephrase the question, maybe i can give a better answer?
EDIT-----------------------------------------------------
tableviewcontrollers will do that to you. basically, they will allow ONE tableview to be inside them at a time. also, this tableview WILL ALWAYS fill out the entire space available. Now, there is an exception to this that you cam make use of: Elements like a NavigationBar or a TabBar are allowed alongside the tableview, since they are required for navigation. So if you can put your stuff in one of these, its entirely fine. This my seem counterintuitive, since when do i want just a naked tableview on my screen? the answer is: more often than not. Tableviews are HIGHLY customizable using the UITAbleVIewDelegate-Protocol specified here:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UITableViewDelegate
Do yourself a favor and read that doc, i almost guarantee that you will save time in the long run.
For Example: You know the contacts app on your iphone? If you go into the details of one specific contact, you will find a pertty sophisiticated presentation of the data, that will even go into editing mode if you tap edit. It has a header, multiple segments, and a footer.
Surprise: ALL OF THAT is just a single tableview in a tableviewcontroller, customized via the protocol. Let me repeat: you are wasting your own time if you try to do it any other way. tableviewcontrollers exist for a reason. usem them
I want to put a uitabbar into a section in uitableview, I have hard time looking a way for it, since I just started doing XCODE in less than a month. Anyone there know the solution for it? Any help is appreciated, and if possible, could you share a link for the tutorial or examples as well. Thanx in advance.
You can't do it in this way. They both are different things but you can have UITableView inside the uitabbar view. But vica-versa is not allowed ...this is not feasible and also not proper as per apple's guideline. So, please make sure not to use in this way...rather go for some other alternative :
like put Custom UIToolBar in header of tableView , having look & feels like Tabbar.
You cannot put a tab bar into a tableview.
I you want to use a tab bar, use it as a sub view of a UIView.
The UITabBar is supposed to contain other views. So no, you cannot add it to your table view. To get the look and feel of the Groupon app, there are two things you could do:
1. Create a custom tableviecell as advised above.
2. Since the toolbar (which looks like a tabbar) is outside the actual table, you can have it as a separate view and reduce the size of the table to accommodate it. Or add the toolbar to the footer view of the table.
I'm looking to make something like the To: field in Apples Mail app. Basically I want a UITableViewCell to stick to the top of a TextView. Actually it is not a necessity that it be a UITableViewCell, as long as I can stick a label, a text field and a button to the top, just as in the Mail composer.
I've tried to put these things on a scroll view, but couldn't figure that out.
Any help is appreciated :)
PS. I know of Three20, but I would much more like to figure out how to make this To: field lookalike myself, with my own code and no dependencies.
I would do this in a table view and the view in the footer of the table view.