iOS - How to get the position of attachment image in UITextView - ios

Does anyone know how get the NSTextAttachment image's position centre in UITextView?
I'm working on an app that allow user to input text and image in a UITextView, and when user click on an image, it will show the image viewer for all images. This is easy, and I have get this done.
Now, I need to create a custom transition from UITextView (in a UIViewController) to the image viewer, I'm struggling to find each image's centre in the UITextView so I can create a snapshot for the custom transitioning.
The custom transitioning is basically the same as iOS "Note" app, when tap on an image, then create an snapshot, move it the right position.
I appreciate any help or idea to solve this problem.

Related

Free Scrolling in Xcode 8.3.3

I want to create a page with a big image as background and buttons that users can interact with.
So imagine I put a big image such as a piece of map into the screen, but I only show a corner of the map in the display. So if a user wants to see other parts of the map, they have to "scroll" and navigate to wherever they want.
Meanwhile I also want to put a button they can tap on, and that button should lead to a php webpage (in-app, not opening in safari or else) or information page about sites and buildings in this location.
I am a rookie and I haven't have any code written down yet. I am thinking about using UIScrollView and UIButton, but am I on the right direction? Any advice?
Thanks in advance!
First you need a way to pinch zoom the image. In this mode, you can drag the image in any direction that you want. A common method can be found here. A scroll view can only scroll horizontally or vertically but with that image zooming, each image can be zoomed in and then dragged to any direction you want. You can have a scroll view with only one image.
After you have the image zooming ready, all you need to do is to create a subview on your screen to cover part of the image view or scroll view, whatever you used.

UIbutton stretch when clicked unexpectively

I am trying to modify a frame work and have encountered the following problem.
I have replaced one of the button image in the framework's xib file with my own one. The image itself is approximately 20Wx20H but I have set the button size to be 40Wx40H so that the clickable area is larger than the actual image.
When the VC is displayed, I see the image to be normal 20x20 aspect ratio. However, when I clicked on the button, it stretches to 40x20 and goes back to default upon release. I was wondering if there is a UIButton parameter that I can disable which was enabled by the framework somewhere? I have done a search on the buttons in the code and could not find anything relating to stretching the button. So I am guessing somewhere in IB there is my solution?
Below are the images for the button when touch down or not touched down.
Have you tried the following?
button.imageView.contentMode = UIViewContentModeScaleAspectFit;
Also are you using autolayout? If yes, what are the constraints?

add ImageView at the background of UIScrollView

i am trying to create a mechanism for changing user's profile image same as whatsapp does , here's how it looks :
this is what i want to achieve
and this is what i have :
in the second image the background of scrollView is in purple colour i want to add here a UIImageView + UIEffectView as shown in the first image which will be immovable (fixed at position ) but i dont know where to start if anybody knows how am gonna do this than please let me know it'll be so helpful for me. thanks

UITextView doesn't keep subviews visible

I'm implementing the a viewController to enter text and images (very similar to Facebook's "Status" entry) and I have most of it complete, however, the last piece isn't working correctly.
The user can select an image and key-in textual data. As more text are added, the images get pushed down. I implemented this by adding UIImageView as subview of UIView, then add UIView as subview of UITextView. They stack up like this:
Top: UIImageView
Middle: UIView
Bottom: UITextView
When I key-in long enough text that it pushes the images down, the images do not stay visible inside the UITextView. I can still see the images if I drag the screen-up, but as soon as I let go, the images bounces down and can't be seen. How do I fix this? Thanks.
You do the followings for this.
1- Have a UIimageView and set your image
2- Draw your UITextview on exact location of image. Means (x,y,w,h) equals
3-Set UItextView background color CLEAR.
and CHEERS

IOS - Set an Image as Form Layout, and X/Y coordinates of Click on an Image

I am having a problem with my IOS app. In my app, I want my home page so-to-speak to be all one large image which people will click to get into various other screens. How do I set it so the image takes up the entire screen, and how do I find out the X/Y coordinates of where someone clicked?
For the image, you can use UIImageView class and set or initialize it to the size of your home screen.
For tap (click), you can use UITapGestureRecognizer class (see the link below)
http://developer.apple.com/library/ios/ipad/#documentation/uikit/reference/UITapGestureRecognizer_Class/Reference/Reference.html

Resources