xcode 和故事板:如何构建用户配置文件视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30501566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xcode and storyboard: how build an user profile view
提问by Tom
how can i build an user profile view like this (Periscope but is similar to many other apps).
我如何构建这样的用户配置文件视图(Periscope,但与许多其他应用程序类似)。
It's a tableviewcontroller? If it is, how can i put the image of the user with background (it's in the first cell or above the tableview?)
这是一个tableviewcontroller?如果是,我怎样才能将用户的图像放在背景中(它在第一个单元格中或在 tableview 上方?)
回答by ignotusverum
I'd build it this way:
我会这样构建它:
UIViewController
with UITableView
+ custom UIView
on top.
UIViewController
顶部带有UITableView
+ 自定义UIView
。
If you want to use already implemented libraries, check this out :
如果您想使用已经实现的库,请查看:
They have pretty similar logic that's described in your question.
他们在您的问题中描述了非常相似的逻辑。
回答by Diyavol Pasa
It is a custom tableviewcontroller. Everything is a cell but it is hard to create only using storyboard. you create a dynamic table view and ad 3 prototype cell for it (1: Blue cell, 2:Grey empty cell, 3: Option Cell). And create a controller and manage the cell with it like:
它是一个自定义的 tableviewcontroller。一切都是一个单元格,但仅使用情节提要很难创建。您创建一个动态表格视图和广告 3 原型单元格(1:蓝色单元格,2:灰色空单元格,3:选项单元格)。并创建一个控制器并使用它管理单元,例如:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexpath.row== 0)
{
HeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:@"headerCell" forIndexPath:indexPath];
cell.name = "foo";
....
}
else if(indexpath.row ==1 || indexpath.row ==3)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"blankCell" forIndexPath:indexPath];
[cell setBackgroundColor:[UIColor greyColor]];
}else{
....
}
}
回答by Mundi
Looks like above is a header view, and below a table view.
看起来上面是标题视图,下面是表格视图。
If the above part scrolls off it is the table view's tableHeaderView
. In this case you can use a UITableViewController
.
如果上面的部分滚动,它是表格视图的tableHeaderView
. 在这种情况下,您可以使用UITableViewController
.
Otherwise you will have to use a UIViewController
with a UIView
as the header and a UITableView
below it, and you have to declare the table view delegate
and datasource
yourself.
否则,你将不得不使用一个UIViewController
具有UIView
作为标题和UITableView
它下面,你必须申报表视图delegate
和datasource
自己。
回答by Jatin Patel - JP
You can achieved same UI with help of bringing UITableView
and add UIView
with blue background as tableHeaderView
like as below.
您可以通过引入UITableView
和添加UIView
蓝色背景来实现相同的 UI,tableHeaderView
如下所示。
UIView *headerView = [[UIView alloc] init...];
tableView.tableHeaderView = headerView;