Achieving dynamically growing TextView inside UITableView - iphone

I am working on fitting a UITextView inside a UITableView. My table is grouped style with only one section and one row. I've looked through various previous questions but I am unable to get this idea working. I want the result to be the same as the "notes" section in the Calendar app on iPad. And Apple has done the same thing in the contacts app as well for notes. Do I need to use view animations to make the tableView row keep growing dynamically as and when more and more text is typed into the textView? What is the correct overall approach to make this idea work? Any pointers would be greatly appreciated. I get the points on how to resize the textview depending on text size and how to modify the height of the table row. But how do I make these work together to give it a dynamic animated feel like in the Apple apps?
Also another thing I noticed is that the cursor always lands at the beginning of the text view due to which the text gets overwritten and ugly on appending. Is there any method to get the cursor to go to next to the last character in the textview when I tap on it again while some text already exists inside it?
Thanks

You can refer to this Post for dynamically growing your uitableviewcell.

This library can help you grow UITextView with auto layout
https://github.com/MatejBalantic/MBAutoGrowingTextView
You can set-up the hooks (either in the library or you set-up the UITextView delegate) to make sure size of the table view cell get's recalculated based on the new UITextView size each time content of the text view is changed.

Related

swift automatically resize UITextView and states TableView cell while user is typing

I'm looking for the best approach to dynamically increase the height of both the UITextView and the TableView Cell height while the user is entering data. Ive searched and found a lot of different answers some more complex than others.
My table has Static Cells
TextView1
Ive added the following to my viewDidLoad
renewalsStratTableView.estimatedRowHeight = 150
renewalsStratTableView.rowHeight = UITableViewAutomaticDimension
But that doesn't seem to do much of anything. I am also not sure on how to dynamically increase the UITextView as the user adds text.
I wrote a tutorial that addresses the exact issue you're having. Most of the answers are too complex and perform unnecessary size calculations on text views.
You're already on a good path by setting the estimated row height and row height to automatic dimension, but there are a few other steps to make your table view fully dynamic.
For example, you have to disable scrolling in the text view and you have to call renewalsStratTableView.beginUpdates() and renewalsStratTableView.endUpdates() every time your user changes text.
For a detailed explanation and a fully working sample code, check out my post.

How to lock a view as the user scrolls

I am new-ish to iphone development and I am trying to figure out how I can fix a view after it has reached a the top of the screen when a user scrolls a window. Then the view would unlock when the window is scrolled down again to go back to its original position. Ive seen this on on a few apps like instagram (with the user name separators).
Does this design pattern have a specific name?
An example (not iPhone though) can be seen on http://mashable.com/ -- Look at "The New Stuff", "The Next Big Thing", and "What's Hot" bar. See how it locks as you scroll down
My solution for you is
create a UITableView
create a UIView separately which will be used as fixed table header
setup the table's tableHeaderView property to conform the UIView's frame
as UITableView is inherited from UIScrollView you can rely on scrollViewDidScroll method in which I properly adjust my fixed header as Y coordinate changes when scrolling the table.
There can be other similar solution for this too but a strenght of this particular solution is that you can manipulate the fixed header's gui element throughout the scrolling easily.
An example is always better than writing down the details so I created for you (and hopefully for others here at SO) a sample project (of course quick'n dirty), which you can find here at github:
https://github.com/codedad/SO_Fixed_TableHeader_iOS
If I'm correct, you're trying to achieve something like the UITableView in the Contacts app?
It uses the sections of the UITableView for the sorted letters and displays them always on top.
Have a look a this question and create custom section headers.

UIImageView and UItextView inside TableView

I'm working on iOS RSS app, and my last view, which is a UIViewController, is similar to the attached image. I inserted in my DetailView.xib, one Image View to pass the images of the RSS feeds and two Text View to pass the title and summary respectively.
The question is, how can i make the same, but inside a UITableview?
you can use custom cells for it and can add this custom cell at particular index. At first index you just add image view and at second index you just add textview.
Check out this pretty good tutorial Custom UITableViewCell Using Interface Builder.
i hope it helps you.
You can achieve this particular thing by using Custom Table View Cell.
Table View gets created using single Table View Cell again and again. It is much more efficient and uses less memory.
You should check this tutorial.
I hope it will help you.
Thanks
You can make TableView height UITableView.automaticDimension and make sure UITextView autoscroll is disabled and constraint should be leading, trailing, bottom and top.
Here's the link this might work for you:
How to make a UITextView Expand with the text like the Notes app

How to lay out scrollable iPhone view

I need advice on the most pragmatic way to layout the following view. As you can see from the image attached, I have a static logo and text that appears at the top of the view, followed by a variable number of items.
Initially, I was going to use a TableView for the variable number of items, that way I would be able to load any given number of cells at runtime.
My problem is that if I drop a tableView onto this view below my static logo and text, when the user scrolls, the static logo and text will remain fixed. I need both the static logo/text AND the tableView to scroll up.
My next inclination is to use a scrollView, inside which I would place my tableView and static logo.
Is this the most pragmatic way to approach the problem? If so, will there be usability issues when scrolling the scrollView vs scrolling the tableView? In my mind this could get messy.
Any advice on the best way to approach this is greatly appreciated.
Using a table view inside of a scroll view is a bad idea and warned against by Apple in their docs. Basically the internal gesture recognizers can conflict and create a clunky user experience. The best path forward would be to go with the tableview (which is a subclass of scroll view) and have two different kinds of cells– one for the logo and one for the repeating contents at the bottom. Make the first cell the logo and adjust the table view's settings to format it to your heart's content.

How do I make an editable detail view on the iPhone with a grouped UITableView?

I want to make a grouped TableView similar to the Apple iPhone contacts application.
I need a lot of standard fields which can be edited, but I would only like them editable once the edit button in the navbar is clicked.
This has been bothering me forever that I could not find a good tutorial.
Thanks in advance.
This is not easy. I just built the same thing because there is nothing available from Apple. I ended up creating a single table cell with a UILabel and a UIView on it. The UILabel is for when the cell is in read mode, and the UIView is for editing. The UIView contains a number of UITextFields. These are the individual fields. I also had to implement drawing code to draw the lines between the fields. Then I had to come up with the code to pass in an address object, load it into the fields, format the text for the label, switch in and out of editing mode (with animation), and finally handling saving of changes and canceling. As yet it doesn't handle tapping the address type to select that from a popup list, but I have most of the code in place for the rest.
This could have been done using individual table view cells for each field. But then you can't select the whole thing the way it does in contacts and adding and deleting addresses becomes trickier.