xcode/iOS: UITextField overlaid onto UITableViewCell with same frame does not match - cocoa-touch

To allow high-performance editing of UITableView cells I maintain a single UITextField which is displayed/hidden as needed. I've extended UITableView so that double-tapping a cell enters text edit mode, at which stage the text field is added as a subview to the tapped UITableViewCell and becomes the first responder. The cell textLabel is purposefully hidden at this point.
My issue is: I set the same frame and same font for my UITableViewCell and the UITextField, yet the two do not exactly overlap. I have produced an image illustrating this behaviour: the left side shows on top the UITableViewCell textLabel, below this is the UITextField overlaid with cell textLabel hidden, and on the right are both made visible.
I'm not keen on "fudge factor" value fixes, so can anyone tell me what's missing?
I am running the app under iOS 4.2 in the xcode iPad simulator.
Many thanks!

Textfield might just align its content differently. Give the textfid a border to see if it really has the same size as your cell's content view (are you adding to that? Or to the cell's view?)
If the textfield and the cell match, I don't see a problem using a fudge factor.

Related

UITableView static cells not adjusting to screen size

Im having trouble resizing content inside static cells to fit different iPhone screen sizes.
Looking at the image below you can see that the UIPickerView and Sign In UILabel both did not resize in width.
I've tried adding code to the ViewDidLoad like so
self.signUp.frame = CGRectMake(0,0,self.view.frame.size.width,self.signUp.frame.size.height);to programmatically adjust their sizes but nothing changed.
I also tried adding equal width constraints to make it match the UITableViewCell contentView width and that did nothing as well.
Same issues happens to all UILabels (Membership,Schedule,Method...) and UITextFields (Comments)
This is all occurring in a UITableViewController.
How can I get it to resize?
Apples freeform UIViewController and UITableView are externally useful in this circumstance.
If you design your app in the storyboard, before applying constraints make sure the UIViewController's size is freeform (big square that doesn't match any screen size).
Then add constrains.
When you run the app, the app will resize properly.

Custom UICollectionViewCell Subview Layout Issue

I have a custom UICollectionViewCell class that sets the background view of the cell to a downloaded image and also a UILabel added to it that sits neatly at the bottom of the cell and is slightly transparent (this label is the title of the image). It looks great in portrait but when I rotate my device to landscape the UILabel stays in its position while the custom cell resizes itself to better fit the screen. I have my UILabel fully constrained to the cell so I don't know why it isn't resizing to always fit the width of the cell whether the device is in portrait/landscape.
I've attached these pictures below to better illustrate what exactly is happening:
I figured it out - for anyone who is also wondering the same thing, this is what I did:
I overrode the layoutSubviews method in my custom UICollectionViewCell class and forced my UILabel to stick to width and bottom of the cell.
It was weird because before I upgraded to xCode 6 and iOS 8 this was working perfectly without the need of this solution (the constraints within the storyboard worked), but now I had to use this approach.
Cheers!

UITable View is filling the entire view

I am working on an iphone application on XCode 4.3 using storyboard.
I have created a view and I need it to be divided in two parts. the top part will contain a UIImageView and the bottom part a UItableView.
So I added both to the view using the storyboard interface builder, and set the sizes and positions of the UIImageView and the UITableView.
However when I run the application, the UITableView will take the entire view (it is being scaled to fill the view). I need it just to stay at the width/height I specified in the IB.
Why does the UITableView take the entire view? and how can I make a view with a UITableView be a small part of the view and not fill it?
I hope I was clear
Thanks a lot for any help
edit:
Screenshot of the storyboard section
the top part has a UIImageView and a "Share" Button
and the bottom part a UITableView
The UITableView is taking the entire view and hidding the rest
Another screenshot requested
I am not using storyboard here, just a xib, but it should matter. This is how you should set it up:
Autoresizing for UITableView:
Autoresizing for UIImageView:
Notice the fixed top margin for image view, fixed bottom margin for tableview, and flexible height for both. This will ensure tableview always sticks to the bottom and expands upwards proportionally, and vice versa for image view.
You would want to play around with this settings of your UITableView
I believe the setting is off making it resize. But I might be wrong.
Note: this is a screenshot of my UITableView inside a view controller and it is NOT filling my screen. It may have a different setting in your case. So play around with the values in there.

iOS table view having text fields scrolling issue

I have a UITableView which is composed of custom cells. There are 21 cells containing text fields.
When I try to scroll and edit the cells at the bottom of the UITableView, I can't manage to get my cells properly positioned above the keyboard.
Also i created a custom cell class separately for my cells. So keyboard delegates are available on that class only.
I have seen many answers talking about changing view sizes,etc... but none of them has worked nicely so far.
Could anybody clarify the "right" way to do this with a concrete code example?
There are three approaches to this problem all of which tie into the keyboard did / will show notification....
When the keyboard appears, you move the whole view (including tableview) up to ensure the selected textfield is shown on screen, you can calculate this by getting the keyboard height (from the notification) and the textfield position.
You can resize the tableview so that it is only as big as the portion of the screen not covered by the keyboard, again get the height from the notification.
You can set the content inset for the tableview (for the bottom value) to the height of the keyboard.
If you need to, when resizing or repositioning the tableview, you may need to set it to scroll the content to the rect of the text field to ensure it is in view...
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;

UITableViewCell with UITableViewCellStyleValue1; how to get cell to resize textLabel to respect detailtext

UITableViewCellStyleValue1 is the cell style that has left-hand black text and right-hand blue detail text.
I can set adjustsFontSizeToFitWidth to ensure that the textLabel respects the width of the cell, but it may still over-display the detailTextLabel. How can I tell the textLabel to adjust it's size for to respect the detailView? Is sub-classing UITableViewCell the only approach?
Yes, the only way that I would tackle this problem is via a subclass. You could do it with what you are given, but you are in the end, you are putting the same amount of work into it, so I would go with the more control you get with a subclass, so if you wanted to change anything in the future you have the power to do so.