I have a UITableView with custom cells. The cells containing one UITextView each and the cell is resizing during user type text in the TextView. My problem is when user is on first row in a TextView autocorrection bubbles wont be visible in the current cell. Is there any workaround or can someone point me to another direction?
alt text http://img340.imageshack.us/img340/5414/skrmavbild20100519kl092.png
If the cell is resizing as the user types, you could set the minimum height of the edited cell to have enough height for the bubbles. Always measure the active cell as if there were at least two lines.
Each UIView has a clipsToBounds property that controls wether contents can be drawn outside the bounds. You might be able to set this to NO for all views in the hierarchy between the bubble and cell. This could have other side effects though.
Also, make sure the active cell has a higher Z order than neighboring cells. It could simply be that the next cell down is drawing over the bubble, as opposed to the active cell cropping the bubble.
I propose you a "workaround"
Your user try to edit a row in your table view
-> You present a modal view with a UITextView with dismiss and ok button.
Related
Currently I have UITableViewCell's that hold sometimes really long text (up to 50,000 pixels in height after drawing). However the UITableView delegate documentation says that cells shouldn't be higher than 2009 pixels in height (any ideas why?).
It's only the first section in my table view that has the really long cell, so instead of using a cell for the first section, I thought I'd create a UIScrollView, put a UITextView as the first "cell" and add it to the scrollView, and then add the tableView to the scroll view as well (under the textView). However, having a 50,000 px high UITextView is causing huge memory problems.
What are my options? I know I could use a UITextView that scrolls, but to have a scrollable UITextView with a tableView just causes complicated scrolling behavior. I want to mimic the scrolling of a tableView.
I didn't know it would be an issue to have a 50,000 px high view in a UIScrollView. I thought that's what UIScrollView's are for? Do I have any alternatives?
I would seriously question the UI design where you must render text that large as part of a table cell. The best option would be to put a reasonably-sized summary in a cell with cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;, build a separate view for the long text, and let the user navigate to that view by clicking the disclosure indicator.
As a side note, you could also put a scroll view inside the initial table cell (not all cells must be of the same type; you can make one with a scroll view in it, and use it for the cell at index zero). It's not going to be as usable as the regular cell with a disclosure indicator, though.
In Weather.app on iPhone, scrolling past the bounds of the Hourly tableview continues to show the alternating table cells, just without any text inside of them (see image below). I was wondering how I could replicate this look. This question provides one solution, but I was hoping there was a more efficient way then just adding an image of blank cells above my tableview.
Thanks
You can use the headerView and footerView properties of the UITableView. These allow you to specify custom UIViews that will be placed before and after your content cells.
So, you should initialize a UIView with some dummy inner views with alternating colors. The height for this UIView should be equal to tableView.frame.size.height. then just do:
tableView.headerView = headerViewWithFakeColors;
tableView.footerView = footerViewWithFakeColors;
Also, you will also need to change the contentInset property so that these fake header&footer views are only visible when the user is bouncing (with contentInset you can control the point where the tableview starts bouncing)
tableView.contentInset = UIEdgeInsetsMake(headerViewWithFakeColors.frame.size.height, 0, -footerViewWithFakeColors.frame.size.height, 0);
I am creating a grouped table with two sections.In the first section i have 5 cells and in the second section i have two buttons in the lass cell of it.
I have created labels and buttons on each of the cells in the first section and the labels are populated dynamically by the values selected in the previous screen.
Everything works fine as expected,except the borders of the table view gets ruined,it looks like half drawn and incomplete.When i make the table view to scroll up and when its back in the original position,the top borders are spoiled and when i scroll to the bottom the lower borders of the group gets affected making them incomplete.
I am setting the label's and button's attributes in each of cell after initializing them in the viewDidLoad method.
Please suggest me an idea to solve this issue.
Thank you one and all
I am setting the label's and button's attributes in each of cell after
initializing them in the viewDidLoad method.
This is incorrect. You should save the texts for the labels & buttons in a model class & set them in the cellForRowAtIndexPath: method. As, you are not doing this in the aforementioned method, your cell is redrawn when you scroll and the texts are nullified.
I have a tableview with custom cells. Each cell has a UITextfield. When the last cell's textfield is clicked, the keyboard pops up and covers it and the table view won't scroll up any further. Is there a property of UITableview that can be set so that the last cell can scroll to half way up the screen?
Thanks in advance
There are a two ways to approach this (that I can think about off the top of my head):
You can use the tableFooterView property of UITableView to set an arbitrary, empty view to be about half the size of your table.
You can add empty cells to the bottom of your table
Both of these approaches will accomplish roughly the same thing, but using the tableFooterView property is probably your best bet.
see Making a UITableView scroll when text field is selected for a list of solution..
Also basing your view controller from UITableViewController (since you say its a table) will provide all this functionality automatically!
In Interface Builder, you have to set the size of the tableview and position the other elements beneath that. I want the tableview to be sized to fit any number of rows and the buttons to be moved down relative to the tableview.
Is it possible to do this without building the whole thing programmatically?
You should embed the buttons within a UIView, and set that UIView as the tableFooterView of the UITableView. You can do this in IB by dragging the view into the bottom of the UITableView. This way the buttons will always be below the last row of the tableview, though I should warn you that if there are more rows than fit on-screen, the buttons won't be visible until you scroll down. If this isn't what you want, then you'll need to do something more complicated (namely, run -layoutSubviews on the UITableView, then ask it for the rect of the last section, and use that to calculate where the buttons should go).