Added UIImageView to UITableViewCell outside cell's bounds - objective-c

I'm adding an UIImageView to my custom UITableViewCell. This image is then displayed outside the bounds of the cell. I've also added a UITapGestureRecognizer to the image so that when I tap on the image it will be removed from the view.
However when I tap on the image there is another cell beneath it that instead reacts on the tap. So it seems that adding a tap gesture recognizer to the image doesn't have any effect. And yes I have set userInteractionEnabled to YES for the image.

"This image is then displayed outside the bounds of the cell." your view will not receive touches outside it's bounds therefore the subview will not receive touches if it's parent does not

Related

UIView in UITableView disappear when becomes firstResponder

In storyboard I have a UITableViewController-->UITableView-->UITableViewSecion--> with static cells
in the same UITableView I also have a UIView that holds a background image and UITextView.
A click on a button shows the UIView and set it's frame, which appears OK, but as soon as I click on the UITextView or make it firstResponder programmatically the keyboard appears and the view disappears
the code when clicking the button
self.myView.frame = CGRectMake(0, self.tableView.contentOffset.y+100, self.tableView.frame.size.width, self.tableView.frame.size.height-100);
self.myView.hidden = NO;
how can I fix this?
Can you copy paste us the code where you add the view to the tableview? Are you doing it with constraints or with frames?
The issue you are having is probably due to the fact the UITableViewControllers automatically shrink the contentSize of the UITableView they hold when the keyboard shows. If you add a UIView to your tableView with addSubview: programmatically, you might need to add a flexible bottom resize mask to make sure when the contentSize shrinks in height, your view stays attached to the top and not the bottom.
Try this on viewDidLoad:
[theViewYouAddedToTableView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];

How to move UIView when scroll in TableView

In facebook app, when you scroll your TableView down, an UIView on the top will disappear with animation. How can i do this in code, that is, access and modify the Y position of the UIView depend on the contentoffset of tableview's scrollview

How to generate a image of uiscrollview?

I have a UIScrollView with subview like UILable and webviews. So when I click on a button all the content of the scrollveiw should generate as a image. I tried to generate it but it is not getting all the content of UIScrollView it is just showing only visible view.
and my code is
[Scroll.layer renderInContext:UIGraphicsGetCurrentContext()];
It is because your scrollView's contentSize is larger but its scrollView.frame is still smaller.
Instead of scrollview, add your content first into a UIView (Let say it containerView). containerView should have height-width stretchable according to your content.
After that add your containerView to scrollView. So your scrollView require contentSize = containerView.frame.size
Now try to taking screenshot for the IBOutlet of containerView, not the scrollView.
I have not tried this out, but I guess it should work in this case.

Make subview of a UIScrollView fixed while the other subviews scrollable

I want to make a View with three subviews stacked on top of each other with the middle subview scrollable with the others fixed.
How can I achieve this programmatically? I have tried
to set the contentsize of the root view to the size of the scrollable view but that makes all the views scroll.
-set the contentsize of the middle subview without setting any property for the root view but that makes all the views unscrollable.
Please help. I am new to iOS.
Thanks in advance
You can use the scrollViewDidScroll: delegate callback on the UIScrollView to adjust your view's position. In the callback, get the contentOffset of the scrollview and use that to set your fixed view's position.
For example, if you want your fixed view to always remain 100 px from the top of the scrollview, set its initial frame to (0, 100, width, height), and then in the callback set the frame to (0, contentOffset.y + 100, width, height).
The result is that the subview will appear fixed at a given height.
If your UIScrollView has a superview (i.e. a container view), you can add your 'fixed' view as a subview of the superview instead of the UIScrollView. You'll only have to calculate your frame coordinates once.
You can do it moving sub view from UIScrollView to super view of scrollview like:
Place/set your button over scroll view (not inside scroll view) as shown here in this snapshot. And also set button constraints (position) with respect to super view of your scrollview.
Here is ref. snapshot of hierarchy of position of each view over each-other.

Drawing on UIScrollView and UIImageView

I want to draw line on image view then image view is to put on scroll view. How to do that? Any Idea???
Set the scroll view's contents to a UIView. Display the image in the UIView, do a setNeedsDisplay on that view, and draw anything you want when the UIView's drawRect gets called.