Appending a scrollview (horizontal) to a view which has a scrollview (vertical) and two labels Iphone sdk - iphone

I have developed an iphone application which has 6 cards (icons with images) in the Rootview. Clicking on a card would bring another view which the image being enlarged (fullScreen). The Card View has a Flip button which shows the back side of the Card which contains some text. Different cards hold different text on their back. Depending on the text size the view will be scrollable. I used two labels: one for title of the text and and second label having the whole paragraph. I have placed a scrollview below the two labels for vertical scrolling.
When a nth card is clicked from the Rootview the selected card should appear. It works perfectly. I used a separate view to design the front view of card and a different one for the text on the back. The issue is when a card is opened and flipped to see the text, it should be scrollable horizontally too apart from scrolling vertically. I dont want to redo anything. I have placed the vertical scrollview and the labels on the view representing back of card. I added another scrollview and enabled its paging property and wrote code in the following functions.
scrollViewDidScroll:(UIScrollView *)sender;
scrollViewDidEndScrollingAnimation:(UIScrollView *)newScrollView.
But it is not working as desired. No scrolling works (even the vertical 1 which was earlier working fine. I mean when i combing the horizontal scrolling both stop working.
How do i allow vertical and horizontal scrolling to this view which has two labels.
I would appreciate your help...
Thanks in advance

I solved it.
I used a table view to hold the card back details. So i get vertical scrolling by default.
I took a scrollview which will hold as many number of tableviews as there are cards.
And it is done

Related

Stack View causes buttons w/ image to go off screen in Swift 3.0

I'm currently making a type of soundboard in Xcode, and I'm trying to get four buttons that all contain the same image to line up with each other horizontally, and have four rows line up vertically in a 4x4 grid. So after I resize all my buttons on my storyboard, I attempt to embed them all in a Stack View. However, upon doing this, the buttons DO line up horizontally, BUT the buttons resize themselves and the Stack View stretches way offscreen. I'm unable to resize the stack view in the storyboard. Does anyone have a solution for this?
A stackView cannot display a grid. It can either contain horizontal or vertical components. Select the first row, put it in a stack view. Do the same for next three. You should now have four horizontal stack views. Now embed these four stack views in another stack view with vertical components.
Lastly, set up your constraints and you should be good to go.

How to use a scrollview containing buttons with auto layout

I need some help figuring this out.
I have a simple UI I need to implement. I have 4 buttons that take up the entire screen and with the scrollview, I want the user to be able to scroll to make the 5th button visible. I know how to use auto layout to make my first four buttons display how I want them. The first button is 40% of the visible screen, the second button is 15%, the third 30% and the last button is 15% of the visible screen. The 5th button should be hidden but then revealed when the user scrolls down.
(To clarify, all buttons have width equal to their superview, proportional height to the superview and all buttons have no spacing between each other)
This is where I am stuck. I want the proportions as I stated above, but also want the 5th button to show when scrolled to, possibly at 10% of the now visible screen (with the first button now not showing itself fully). Is there a way to do this?
You can set the contentSize of the UIScrollView to be larger than the visible screen. The buttons can be sized and placed in a way to have all 5 buttons visible (with the 5th button actually off screen). The scrollView will bring the 5th button into view when scrolling.
I worked up a simple prototype using just a storyboard (and setting the contentSize of the scrollview in Runtime Attributes section, but this could be done in code if you need to pragmatically determine the button sizes.

UITableView background image for content

I have UITableView with height = 1000px, I need to set scrollable background.
I know how to set background image for tableview but in this case that background image will not be scrollable.
Right now the only idea how to do that is:
1) create scroll view with proper height (about 1000 px), and set background image for that scroll view. then set frame of UITableView as the bounds of scroll view (and disable scrolling for UITableView).
But my idea is rather bad, because I have many cells with many images on them, and in my approach all the cells will stay in memory.
What is the best way how to implement scrollable background inside tableview?
P.S.
I have tableview header of unknown height (depends on the response from server)
If it's a repeatable pattern, one way would be to split the image, repeat the middle part and show the top/bottom only when the contentOffset reaches the boundaries of contentSize. Or set the top/bottom parts only for first/last cell and the center (repeatable part) for every other.
Edit:
As I said, for a repeatable pattern:
You crop the elements you'd use for header, footer and middle
Of course, for header & footers with information in them you'd probably need bigger header/footer images:
Get the parts and assign them as backgrounds in your cellForRowAtIndexPath: method. You can do the whole thing with a single image without separating the cropped parts in different files, that's already discussed here.
There is some example code in the official docs on how to make a "synchronized" scroll view. Since a table view is a scroll view, it should work to synchronize with a table view as well. So make your background be a scroll view behind the table view, and synchronize it.
The critical step is this:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(synchronizedViewContentBoundsDidChange:)
name:NSViewBoundsDidChangeNotification
object:synchronizedContentView];
Then it's simple in your handler to match up the content offset of your background vs. the table view.

Scrollview and image dragging issue

I have a scrollview that has a number of custom imageviews in it. I use the custom imageviews as I need to be able to drag any one of them off the scrollview and to another location on the iPad screen, bit like a photo picker.
Problem is if I want to scroll the scroll view most of the time the custom imageview gets the touch and moves rather than the desired scroll?
I notice in the sample code from Apple using the autoscroll example that they have the same issue but they have left a large gap between the images....ugly!
Is there a way to let the app know when you want the touch to be a scroll and when to be a drag?
Thanks
You could make a drag require holding for 1 second, similar to the behavior of the home screen when in editing mode: if you want to scroll, you just flick; if you want to drag, hold down for a moment until the icon enlarges, then you can move it.

Why can't I tap input elements after I resize a scroll view?

I have a sample project that uses the metrics from notifications for resizing the keyboard when a text field is focused.
http://www.smallsharptools.com/downloads/ObjC/KeyboardSize.zip
The series of text fields are all wrapped inside of a UIScrollView and when the keyboard is shown a notification is sent with the height value. I use that to decrease the height of the UIScrollView so that all of content can scroll inside without being covered by the keyboard.
But I find that when I do this the other text fields sometimes cannot be tapped. They seem to be covered with a layer that I cannot see.
What can I do to ensure that the input elements in the UIScrollView remain accessible when the height is changed?
FYI: You can see in the sample project there is a blue marker on top and another red one at the bottom. The view controller which handles the resizing is CMScrollingViewController which is inherited into KeyboardSizeViewController so that this behavior can be used by multiple view controllers.
I am hoping that this problem can be fixed so this simple code can be reused.
I figured out my problem. I was setting the view which goes inside scroll view to flex the height and width using the autoresizing mask. Once I commented out that line of code this problem went away. It seems it was resizing the view but I could still see the contents of the view but it was outside the bounds of the view so it could not respond to taps.
//self.subView.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);