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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:12:52  来源:igfitidea点击:

xcode and storyboard: how build an user profile view

iosxcodeswift

提问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 上方?)

enter image description here

在此处输入图片说明

回答by ignotusverum

I'd build it this way:

我会这样构建它:

UIViewControllerwith UITableView+ custom UIViewon 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 UIViewControllerwith a UIViewas the header and a UITableViewbelow it, and you have to declare the table view delegateand datasourceyourself.

否则,你将不得不使用一个UIViewController具有UIView作为标题和UITableView它下面,你必须申报表视图delegatedatasource自己。

回答by Jatin Patel - JP

You can achieved same UI with help of bringing UITableViewand add UIViewwith blue background as tableHeaderViewlike as below.

您可以通过引入UITableView和添加UIView蓝色背景来实现相同的 UI,tableHeaderView如下所示。

UIView *headerView =  [[UIView alloc] init...];
tableView.tableHeaderView = headerView;