I have a UITextView at the top of a UIView, below many UIControls are there like buttons, table view... Possibilities are user can give multiple lines in UITextView, in that case I have to expand(increase height) for UITextview to show two lines, If UITextview height increase every other controls should go down accordingly, How to do it in iOS ? I heard android they are auto arranging easily, Is there any way to do like this in iOS?
Where should I concentrate? Any ideas will be helpful. Thanx.
You should use autolayout for achieving this.
raywenderlich autolaout
developer.apple.com
Auto Layout video tutorial
About Cocoa Auto Layout
This tutorial helps you to understand autolayout in a better way.
You could look at auto layout, it's available from ios6 onwards. It will allow you to easily (some even non programmatically) specify constraints to be maintained while the view hierarchy is being displayed. For a good tutorial see this.
If you are working on iOS5 or below I would recommend the following :
I am assuming that all your views are direct children of the textView, even if that isn't the case the grandchildren views (and further ancestors) will move automatically once their parent moves down.
for (UIView* view in yourTextView.subviews)
view.transform = CGAffineTransformMakeTranslation(0,Y_DELTA_VALUE);
//Y_DELTA_VALUE is the amount you want to move the subviews down by, the
//(amount of height the textView increases by)/2
Related
I am new to iOS/Mac and ObjectiveC development and need a bit of guidance if someone could be so kind, so please excuse my ignorance.
The issue I have is I need to create a Grid view for a TV Guide where you have a vertical list of channel logos on the left that scrolls up and down, and to its right we have a horizontally and vertically scrolling grid. Horizontal scrolling doesnt move the channel logos which is fixed on screen, but vertically scrolling grid also scrolls the logos as you would expect.
Now being new to ObjC and iOS Frameworks, I was wondering which methods I should go down to implement this, Quartz2D perhaps? Or are their alternative simpler methods?
Whatever method is used, it needs to be quick with thousands of 'cells' across up to 600 rows; it also has to be memory efficient with out of view cells being disposed/reused as needed.
I am not necessarily asking for specific code (although that would be nice lol), just some advice on what methods to use so i can concentrate my education on those areas; if that is possible
Thanks.
It seems you do not really need two different scroll views / table views left and right, as the two sides should always scroll with each other.
Thus, just use a UITableView with a custom cell (subclass UITableViewCell) that has the logo on the left, and another scroll view (for horizontal scrolling) on the right.
Read Apple's Table View Programming Guide, and you will be on your way.
In my app I have added a UIView as a new subView, however it covers up a UISegmentedControl. I was wondering if there's a way to move the UISegmentedControl back on top so its fully visible?
If you take a look at the docs for UIView you'll find that there are several options:
-insertSubview:belowSubview:
-insertSubview:atIndex:
-bringSubviewToFront:
-exchangeSubviewAtIndex:withSubviewAtIndex:
Also, take a look at View Architecture Fundamentals for an overview of how views relate to each other.
I have requirement where I have to show some images which are differentiated according to Groups they belong to. I have used a table view to view images listed under groups. User has to scroll horizontally to view more images in a particular group.
Can we add a scroll view to tableview row to allow user to scroll list of images horizontally?
I searched a bit, some comments say its not allowed in apple's HIG some comments say
You can add a UIScrollView to a UITableViewCell and as long as you set the contentSize property of the UIScrollView correctly then the UIScrollView will scroll correctly in the horizontal axis
May I get any confirmation on this ??
Or any alternative approach to achieve horizontal and vertical scrolling for different data without using tableview
Yes it is definitively possible and reasonable.
Here is an excellent tutorial by Felipe Laso that explains it step by step:
How To Make An Interface With Horizontal Tables Like The Pulse News App: Part 1
How To Make An Interface With Horizontal Tables Like The Pulse News App: Part 2
BTW, the approach described in that tutorial is way more efficient than adding a UIScrollview to each cell.
Of course you can add scrollView in tableView.
UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 100)];
[cell.contentView addSubview:scrollView];
Now you can set properties for scroll view accordingly.
Sure, this is possible. A UIScrollView inside a UITableCellView will work fine - the HIG says no, probably because it'll be hard to use. The user would have to accuratley scroll either up/down, or left/right and it might be annoying. Shouldn't take long to knock together a quick test.
I have an app with 2 scrollviews - one that allows horizontal scroll, and then inside that another scrollview which allows vertical scroll. The idea is that the user can flick up/down a page, then also flick left/right across pages.
It's not that nice to use, but it's what my client wanted ;)
To make a UIScrollView only respond to horizontal or vertical scroll is all about setting the correct contentSize. Hope this is some help.
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.
I have 5 pics to display (one at a time) in a UIPageControl way, so whenever i scroll (right or left) another pic will show. i can't find a sample code for that!
i searched a lot and apple's sample code is complicated i need a simpler one.
Actually what you are looking for is UIScrollView with pagination. UIPageControl is the small dots that is mostly(not necessarily) positioned on the bottom of scroll view. You have to configure it separately.
To enable paging in a scroll view, you need to set its pagingEnabled property to YES.
The following UIScrollView paging tutorial may help you.