How to lay out scrollable iPhone view - iphone

I need advice on the most pragmatic way to layout the following view. As you can see from the image attached, I have a static logo and text that appears at the top of the view, followed by a variable number of items.
Initially, I was going to use a TableView for the variable number of items, that way I would be able to load any given number of cells at runtime.
My problem is that if I drop a tableView onto this view below my static logo and text, when the user scrolls, the static logo and text will remain fixed. I need both the static logo/text AND the tableView to scroll up.
My next inclination is to use a scrollView, inside which I would place my tableView and static logo.
Is this the most pragmatic way to approach the problem? If so, will there be usability issues when scrolling the scrollView vs scrolling the tableView? In my mind this could get messy.
Any advice on the best way to approach this is greatly appreciated.

Using a table view inside of a scroll view is a bad idea and warned against by Apple in their docs. Basically the internal gesture recognizers can conflict and create a clunky user experience. The best path forward would be to go with the tableview (which is a subclass of scroll view) and have two different kinds of cells– one for the logo and one for the repeating contents at the bottom. Make the first cell the logo and adjust the table view's settings to format it to your heart's content.

Related

make view controller scrollable with collection view

I need to create a view controller like this or like user instagram's profile
not exactly same, I just want to add label and buttons and collection view,
but I want all of this in scroll viewController
I think I can't do that from storyboard, so how I can make a view controller scrollable programmatically?
and then I want to add the label and buttons inside the scroll , I can do that programmatically , but how I can add collection programmatically inside it?
One of the possible solutions is to make the whole container a "UICollectionView" -or "UITableView", depends on what exactly you want to build-, and then, create a custom cell for each area depending on what do you want to display in it.
It might sounds a little bit strange in the beginning, but you will notice that it is a great technique to handle scrolling in your scene, including some of extra nice features, such as:
auto scroll content resizing for "UIKeyboardWillShowNotification" and "UIKeyboardWillHideNotification" events.
the ease of showing and hiding sections from the UI (actually they are cells!).
UPDATED: For example:
You can make the first part (red rectangle) as a UICollectionReusableView and customize it by adding your images and button in it, second part (blue square) as a UICollectionViewCell and so on...
This is the general idea of what how you can do it.

Better to use UIScrollView or UITableView for horizontal buttons?

I have a page enabled scrollview on an iPad. On the first page, I have a child scrollview that scrolls horizontally through image buttons. The buttons scroll the outer scroll view to the correct page. Its basically like a table of contents that jumps to the correct page.
My end goal is to be able to categorize the buttons seen in the child scroll view. So there would be a segmented control that changes what buttons you can see. So maybe one category would be ALL, and another category would be A-M, and another would be N-Z for example.
My question is, should I use a uiscrollview or a uitableview?
Right now I use a scrollview and it is really easy to get the buttons in. I could implement the different categories kind of gimmicky by having all of the buttons in the scrollview and then just showing or hiding the buttons accordingly. I feel that it'd be bad memory usage though.
For a uiscrollview i was looking at using EasyTableView, butI'm not 100% sure if this is compatible with what i want to do or if it'd even be better.
Any ideas for what the best way to implement this is? Specifically, I'm not sure of the best way to change the buttons when I change categories.
Thanks!
Use a tableview when you are dealing with data that is best expressed as sections and rows.
I think for your situation I'd have a UIView subclass that can display the images you need for a given category. Stick that on the outer scrollview as needed. You can keep memory low by only keeping the currently visible view and the ones on either side on the scrollview. When you scroll to a new location you can recreate the view needed for that page, and the ones surrounding it. Then you release the ones that are far away and let the system reclaim their memory if needed.

UIScrollView always bounce upwards and does not show scroll bar in iphone

This is probably simple but I do not seem to get it to work. I have a view and inside it I have a scroll view and inside it I have a view with some labels and a button. the height of the text inside the labels changes according to some condition so I need to scroll down to see it. But whenever I try to scroll down it bounce back up without giving me a chance to view the rest of the view.
Basically, I want when I scroll down, the view to remain down as it normally should. Besides I do not see the scroll bar at all when I'm scrolling.
I know I probably do not understand how scroll views work, so I'd appreciate any help to explain to me the behavior of scroll views.
P.S. I built my whole view in a nib file and this specific setup That I mentioned at the beginning is based on a suggestion from one question I read here.
Thanks, Mohsen
you need to set content size of your scroll view
[scrollView setContentSize:CGSizeMake(360,1000)];
you can make the content size dynamic as per your calculation.

Multiple UITextFields grouped together like a UITableView section

I'm looking for a clean way to implement a login screen in my iPhone application. I'd like it to appear as a grouped UITableView section with rounded corners and a separator line below between rows (like e.g. the sections in the Settings app). However, I'd like to give it a slightly smaller cornerRadius than the default setting of a UITableView section.
Another thing I'd like to do in that screen is to add a "register as new user" button which causes the whole screen to slide up, presenting the registration screen. There will be a background image that spans both screens vertically and should slide up with together with the content.
I was first thinking to just make a UITableView, set it to grouped, add two sections (one for login and one for registration), add some space between them and disable manual scrolling on the UITableView. However, I found that putting a background image correctly behind a UITableView and to make that scroll together with its content is a bit tricky..
Perhaps I shouldn't be using a UITableView and just write some code myself that can wrap multiple views (each containing a label and a textfield) together into something that appears like a UITableView section? I've been searching around but surprisingly it appears that not too many others are trying to solve this same problem.
Any suggestions would be very welcome!
Sounds like a UITableView is overkill for what you need. I would just create a custom UIViewController and have it handle the layout of all of your subviews as well as any animation you desire.
Just have the parent view take up more space than the device's screen. Then, when you want everything to slide up, animate a change to that view's frame property.

iPhone: How to Place a Scrollview Inside of Tableview Cell

I want to put a scroll view inside of the table view cell. I have a number of buttons in one cell of table view and I need to scroll that cell to show the appropriate button.
If you want to use a vertical scroll view then I wouldn't suggest you doing it because, as TechZen wrote, there will be a mess in this case.
If you want the inner scroll view to scroll horizontally then it might be achieved by 2 ways:
Implement a custom table view cell that will include a scroll view inside it.
Add a scroll view as a sub-view to your cell that you will return from tableView:cellForRowAtIndexPath: method.
I suggest you to use the second approach.
There are plenty of examples online. Usually the sub-views are labels or image views, but it is not complicated at all to add a scroll view instead...
I don't think you can do this. It would require nesting of scrollviews which isn't really supported.
Even if it was, it would be very difficult for a user to know which scrollview they were hitting with their pudgy finger. Remember, you don't have the one pixel precision of a mouse on the iPhone. You have an area of at least 15x15 pixels. You don't have a scroll bar but instead just drags anywhere on the screen.
Instead, you should use a master-detail pattern. Selecting the cell in the tableview pushes a detail view which has the scroll view with all the buttons.
Why do you want to do it like this?
I think the best idea is to draw your table view manually above your uiscrollview. I did it, and it works. It just takes more effort and drawing accuracy. But that takes a lot of time. :)