iphone copy/paste menu not shown in UITableViewCell - iphone

I placed a UITextField and a UITextView in a tableviewcell. When tap on text in them, it allows me to enclose a portion of the text with a rectangular popup showing the enclosed text enlarged. I want to either copy or paste over the selected text, but the copy-paste menu never show up whether I single tap, double taps or press and hold. I appreciate any hints you can give.

Somehow the copy/paste menu starts showing up when I tap the textfield or textview. Not clear on what I have done that made the difference. But I can tell you what I did for your reference. I tried to married NIB file, Custome UIViewController, UITableViewCell into one. I had the textfield and textview embeded in a UIViewController. The UIViewController userinterface is loaded from a NIB file. I then have the UIViewController view added as a subview into the tableViewCell. You can do some googling on this. There are many suggestions.
I do agree with some people who advice not to load NIB into an UITableViewCell. In the end, I took the advice and coded the user interface entirely without the NIB file. I declared a subclass of UITableViewCell then had thd user interface constructed within the initWithStyle. This way the custom tableViewCell was readily useful in the tableView without the headache of figuring out how to load the NIB file and how to make the UIViewController reuseable as a tableViewCell.
Since the code was a lot cleaner, I probably accidentally removed the bad code that had broke the copy/paste mechanism.

Related

Problem connecting outlets when UICollectionViewCell is in a xib

I have a custom UICollectionViewCell defined in a .xib that is connected to a custom class file. I am able to register and display this empty cell in a collection view. I'm even able to set values for the cell like background color in the awakeFromNib function in the custom class. As soon as I add a label (myLabel) to the cell in the xib and make an outlet for it in its custom class file, I get a "this class is not key value coding-compliant for the key myLabel" crash when I run. What is causing this?
I searched through the suggested duplicate question and wasn't able to find a cause there. I think the problem may have more to do with my xib containing a UICollectionViewCell instead of a UIView. Perhaps I'm missing something that requires special attention when setting this up.
I ended up fixing this by deleting the swift file and xib file for the UICollectionViewCell and starting over. Not necessarily an answer to the problem but easier than wasting time trying to fix a file that was small to begin with. On the second try though when I made the class file I checked the box to automatically create the xib. This is better than making the two files separately as Xcode will put the collection view cell in the xib for you.

What is the easist way to disable the cell selection of static UITableView in UITableViewController either in Storyboard or code

I want to make "tableViewcell.selection = .None" , either by storyboard or code with minimum lines. I have tricks to do it, but I really willing to know if there is any other easiest possible way exist which I may missing in the apple documentation.
I am working with below components:-
UITableViewController
UITableView (Static)
UITableViewCell (no IBOutlet connected because its not required for my simple implementation)
Subviews of UITableView has IBOutlets
In .swift, didSelectForRowAtIndexPath defined because I want user interaction on click (no delegate method called because so far not required)
Is there any way to disable cell selection from storyboard.
Set the selection style of cell to None in storyboard.
Refer this:
https://developer.apple.com/reference/uikit/uitableviewcell/1623221-selectionstyle

Labels and images above TableView don't show up on device

So, I've laid out a UITableViewController with two prototype cells, and a view in the TableView's header area. In the header area, there are two views that each hold an icon and a label, Friends and Groups.
It looks all good in the Storyboard Editor, but when the screen actually loads, the images and labels in question are gone. I'm fairly new to iOS, so I haven't run into this before. Here are a couple screen shots to illustrate:
In the storyboard editor:
On the simulator:
Any thoughts? Thanks in advance for your help.
You've implemented the data source methods in your view controller, correct?
If not, UITableView will call a method that its data source implements: tableView:cellForRowAtIndexPath: from the UITableViewDataSource protocol, where you would return the cell to use, in this case the cell with the Identifier that you specified in your Storyboard.
We figured out that this was because the tableHeaderView of a UITableView is really weird about updating/redrawing. It's very difficult to get it to act in any sort of expected behavior.
Instead of using UIImageViews, we used UIButtons. The buttons seem to know how and when to updated and redraw themselves, so that worked.

Why won't UITableView 'Auto-scroll' when editing UITextField (in UITableViewCell)? (iPhone)

I have created a UITableView that is of type UITableViewStyleGrouped. I have then created several different sections with a few rows in each. Within each of these rows I have created a custom UITableViewCell that contains a UITextField. I also have one UITableViewCell that contains a UITextView.
I have also implemented a UIToolbar that appears on top of the UIKeyboard that allows the user to move through the UITextField's by pressing previous or next.
The issue I'm having is two-fold:
I need the UITableView to scroll so that when the next UITextField (or UITextView) becomes the first responder it is visible (even with the keyboard being displayed).
When a UITextField (or UITextView) is selected (without using the previous and next buttons) is should adjust so that the field is visible above the keyboard.
I have looked around at lots of different tutorials however none of them have resolved my issue. Any help you could offer would be hugely appreciated.
ADDITIONAL INFO:
I'm 100% certain that my app used to do all of the above automatically, however I seems to have stopped doing it now and I don't understand why. Is there a reason why this may of happened? Is there some function or something that I may have changed that would destroy this behaviour?
Probably no use to original poster now, but those having an issue like this where it once did work and then stopped...
check you don't have a:
- (void)viewWillAppear:(BOOL)animated
in your UITableViewController subclass!!!
using viewWillAppear in a UITableViewController breaks the "automagic tableView scrolling up when keyboard appears" behaviour.
I only found this by comparing laboriously an old version of a project where it did work with my latest source where it had stopped working.
Check out TaggedLocations sample code from apple. It does the same thing without any extra manipulation.
The key is that your viewcontrollers are following the standard. i.e you are NOT having container viewcontrollers such as UINavigationController within UIViewController.
You have to update tableview Frame yourself programatically...
and i am 100% sure that if you are 100% certain that your app used to do all of the above automatically ...than it is not your app.
Check the docs..here is the link
https://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/ManageTextFieldTextViews/ManageTextFieldTextViews.html#//apple_ref/doc/uid/TP40009542-CH10-SW1
You will have to register for keyboard notifications..and then update your tableview frame.
And for next and previous.. you have to programmatically check which textfield became active..and then set the frame accordingly.

Changing the text in a UITextView at runtime

I have a ViewController consisting of just a textView. In its viewDidLoad method, I simply initialize the textView and add it as a subview. In my main ViewController class, when the user presses a button, I switch views and display the view that has the textView. I am trying to change the textView's text however it is not working. Can I not change the text of a UITextView at runtime?
Thanks.
You should keep a reference to your text view.
If you do, then make sure that the reference is correct and valid before setting the new text.
In general, it always helps when you post a problematic code - this way it is much easier for us to help you...