UITableViewCell as subview? - cocoa-touch

I want to reuse views and code
Is it ok to add a UITableViewCell as a subview to a common view and not in UITableView?
Is it a good idea?

I don't think it's a good idea. UITableViewCell is made to serve as a cell and nothing else. Just like UIButton is made to be a clickable button. But you might think "well the button looks good, shouldn't i reuse it just as a subview?". No, you shouldn't do that. Button is a button, cell is a cell and so on. If you want to reuse your code then you should provide a kind of custom UIView and let it be subview for your cell or anything you want

Related

How to always stick button and label together

I want to have a button and label who always stick together. I want it to be static and I found a solution which uses the UICollectionView with cells. I got the "Connection "" cannot have a prototype object as its destination" and found a solution here: Strange error when adding items to prototype cells in storyboard-IB but the answer given there is talking about a dynamic one. What is the right way to do this? I don't need to have a #property from the cell, I only need to have a #property from the button and label and I just want the label and button to stick together. So actually something like this:
You should make a UIView with a UIButton and a UILabel as its subviews.
If you want to use UITableView or UICollectionView, this parent UIView will actually be the UITableViewCell or UICollectionViewCell.

scroll last Cell to top of UITableView

on my last cell is a dynamic textview. With bigger contentSize it will be stay on top of the tableview (to see it, while you fill it on keyboard), but if the textview and also the cell is going to be dynamically bigger: [tableview beginupdates] and [tableview endUpdates] will delete my contentSize. And after that it is scrolling it down to bottom of tableview.
Any ideas how to scroll the cell to the top, and create the cell also dynamically without changes on contentSize? maybe I'm thinking on the right way, ideas?
EDIT
Hmm..not any "correct" solution found...the best way for this purpose is to try set any new cells or sections below the textview to get this cell easy to top of the view. After this its easy to use it with beginUpdates and endUpdates. The cursor will be always in the textview, textview will be dynamically bigger also the cell, so the only easy way.
Another option is to set the uitableview as a subview of another scrollview (uitableview himself has one) to scroll up an down in the new scrollview.
Thanks for help.
From my experience, Text views in cells is a very tricky issue. I recommend just using the free Sensible TableView framework, which has text view cells available out of the box.

UIPopover from UIButton in UITableViewCell

I have a UIButton inside a cell that is inside a tableView.
When the button is clicked, I want a popover to show up at that button.
Are there any examples of this?
Note: I am new at this, and still not familiar with coding.
Thanks
The View Controller Programming Guide is a good place to start:
And these example apps use popovers:
http://developer.apple.com/library/ios/#samplecode/MultipleDetailViews/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009775
http://developer.apple.com/library/ios/#samplecode/ToolbarSearch/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009461

Custom UITableView Cell

What is the Right Way to Implement This?
For example, say I created an XIB file with a button in it. Say a button on that custom controller get pressed, how do the program knows which "row" of the UITableView get pressed? Does each row has their own UITableViewCell Controller?
There has to be one right way to design this.
You can follow the tutorial for custom cells -
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
You are asking about two different controls (buttons and cells), but anyway both have a similar way to "communicate" with the controller. With the button's tag and the cell's index, you have enough to be able to manage the use of these controls.

Click UITableViewCell to set focus in UITextField in iPad

I have seen related questions asking how to set focus at startup with firstResponder, but this is a little different.
When I click on a certain UITableViewCell, I want to set the focus in a specific UITextField. Is there a way to set the focus of the UITextField in this manner?
Thanks.
You can override TouchesBegan on your custom TableViewCell to make the UITextField as the first responder
Assuming you have that cell you want then all you need to do.
[yourTextField becomeFirstResponder];
Also remember the setTags:(NSUInteger*) and viewWithTag: Methods to get cell subviews you have placed.