开发者

TableView,label and Textfield on ScrollView

开发者 https://www.devze.com 2023-04-10 13:54 出处:网络
In my app I need to do something like this: Fi开发者_开发技巧rst of all I have a tableview that contains 3 section (2 of them with 3 rows). Below this tableView I have to put a label,and below the lab

In my app I need to do something like this:

Fi开发者_开发技巧rst of all I have a tableview that contains 3 section (2 of them with 3 rows). Below this tableView I have to put a label,and below the label a textfield.

I tried to do this on xib file. I put a scrollView, and on this scrollView I put the tableview,the label and textfield. The problem is the view is not enough for all of them.

First of all,I want to see the tableview on screen and after I scroll the screen to see the label and textfield . I don't know how can I explain this...I mean that when app starts to see only the tableview on screen and after scroll to appear the label and textfield. Is it possible what I'm trying to do?


You have added those views (Tableview, label, textfield) in the nib file right?

Link all them to different variable to refer them.

set the frames through coding. like

tblView.frame = CGRectMake(0, 0, 320, 416);
label.frame = CGRectMake(60, 420, 200, 50);
textField.frame = CGRectMake(40, 480, 240, 31);

finally set

tblView.scrollEnabled = NO;
scrollView.contentSize = CGSizeMake(320,520);


UITableView is scrollable and i don't think that you need to take a UIScrollView for your task.You can add a label as a cell row textlable and a UITextField as an AccessoryType in your TableView.
Hope it would help.


There can be two approaches for your problem.
First approach :
No need of taking a UIScrollView. You can shorten your UITableView height and fit all three views on your screen.
Second approach :
Increase the content size of UIScrollView (increase Y parameter).


Yes it is 100% possible. You need to go through two types of tutorials and then you can integrate them for your own use.

  1. You need to learn how to build customized table cell.

  2. You need to learn to create table with multiple headers.

You don't need to use scrollview at all as it is already there in tableview. Or in simple words tableview is build on scrollview. So scrolling property is inherited.

Merge both techniques and you will have you custom tableview. It would not be easy but definitely you can achieve it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号