Does UITableViewCell accessoryView has superview? - ios

I assigned a UIView to a UITableViewCell's accessoryView then when i try to get the superView of it seems it's nil?
So does accessoryView has a superview? If no how does it appears?

A view cannot appear on screen unless it has a superview (or is itself a UIWindow).
You may be checking the superview property before it has been set. The accessory view is added as a subview of the cell by the cell's layoutSubviews method. It doesn't happen immediately upon setting the cell's accessoryView property.
If you replace an accessory view with another accessory view, the old accessory view will be removed from its superview (the cell) immediately (inside the setAccessoryView: method), but the new accessory view won't be added to the cell until the cell's layoutSubviews runs.

Related

TextView In TableViewFooter within CollectionView scroll on keyboard

I have TextView inside a TableView FooterView and that TableView is inside CollectionViewCell.
How to have the TextView move when pressed. Now Keyboard collapses with the textView. It does not scrolls the TableView up by default.
You can use IQKeyboardManager. It will handle all keyboard events.
Take the reference of the bottom constraint of your tableView and then change the constraint constant to keyboard height, then the bottom of your tableView as well as the textView will come just above the keyboard.

DidSelectItemAtIndexPath not called for UITableView inside UIScrollView

My self.view has a UIScrollView as a subview. This UIScrollView has a container UIView, which holds many UITableView's as subviews. These subviews are all configured using autolayout constraints.
So basically my scrollview is horizontally scrollable. I also have UILongPressGesture inside my UIScrollView.
My problem is didSelectItemAtIndexPath is not called while tapping over the cells inside UITableView. I have set cancelTouchesInView to NO for my UILongPressGesture but still didSelectItemAtIndexPath doesn't get called.
I don't want to add UITapGestureRecognizer to my UIScollView and manually trigger didSelectItemAtIndexPath , since I'm doing some operations in UITableView delegate methods.
How can I make my UITableView to responds to all of its delegate methods ?

How to keep subview on UITableViewCell

When the user taps the accessory view, the profile image in the UITableViewCell gets darkened by a black view that gets added on as a subview.
Here is what the cell looks like with the black subview:
Here's the issue: When I tap on another cell, the subview gets removed from the first cell and added to the second:
I would like to keep the subview for all cells that have been tapped.
Here is the code in which I handle that functionality:
self!.profileImageBlackView.cornerRadius = cell.followUserImage.frame.height/2
self!.profileImageBlackView.frame = cell.followUserImage.frame
cell.followUserImage.addSubview(self!.profileImageBlackView)
cell.followButton.hidden = false
For some reason, the follow button gets added to both cells, but the "profileImageBlackView" gets moved from cell to cell depending upon which one was activated.
You cannot display the same view in different cells. If you add the view to another cell it's removed from the first one. You must create a separate view for each cell.

How to clip table view cell to view above

I have custom tableViewCell and View above it in tableView. After taping on button views height increase and cover cell's view. How to clip cell to bottom of view for changing position of cell and don't allow view to cover cell?
I tried to override setFrame: method in my cell. But it doesn't work.
If the view above the cells is a table header view, you should reset that view as the header after you increase its size. So, if you're view was called myHeader, you would do this after changing the size ,
self.tableView.tableHeaderView = myHeader;

iPad - UITableView with UITextField - Autoresizing problem when orientation changes

In my iPad split view application, I've a table view in detailed view as well. Each row has a text field. When orientation changes, the table field in table view is extending out of table view.
Can some one tell me how to set the auto resizing mask so that even when orientation changes, the text fields will be within the table view?
if you add tableview as subview of UIView then:
[self.view setAutoresizesSubviews:YES];
[tableView setAutoresizesSubviews:YES]; or set in IB
while creation of cell set like this:
[urcell setAutoresizesSubviews:YES];
if u add textField as subview of cell. So that it will handle all of its subviews while orientation

Resources