Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/133.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UISegmentedControl在UITableView上显示多个数据集_Ios_Swift_Uitableview - Fatal编程技术网

Ios UISegmentedControl在UITableView上显示多个数据集

Ios UISegmentedControl在UITableView上显示多个数据集,ios,swift,uitableview,Ios,Swift,Uitableview,我的UITabBarController中有一个ViewController,加载它需要5-8秒的时间 没有繁重的处理,没有显著的回调链,也没有网络调用 我刚才问过这个问题: 我想我已经指出了问题的根源,所以我将在这里详细介绍 我有一个UITableView,其数据源根据UISegmentedControl的值更改。我正在显示好友请求,分段控件管理传出的和传入的请求的显示 override func viewDidLoad() { super.viewDidLoad() fr

我的
UITabBarController
中有一个
ViewController
,加载它需要5-8秒的时间

没有繁重的处理,没有显著的回调链,也没有网络调用

我刚才问过这个问题:

我想我已经指出了问题的根源,所以我将在这里详细介绍

我有一个
UITableView
,其数据源根据
UISegmentedControl
的值更改。我正在显示好友请求,分段控件管理
传出的
传入的
请求的显示

override func viewDidLoad() {
    super.viewDidLoad()

    friendRequestsToDisplay = FriendRequestManager.instance.incomingFriendRequests

    tableView.delegate = self
    tableView.dataSource = self

    self.refreshControl = UIRefreshControl()
    self.refreshControl.addTarget(self, action: "refreshRequests:", forControlEvents: UIControlEvents.ValueChanged)
    self.tableView.addSubview(refreshControl)

    incomingFriendRequests = FriendRequestManager.instance.incomingFriendRequests
    outgoingFriendRequests = FriendRequestManager.instance.outgoingFriendRequests
}

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return friendRequestsToDisplay.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let bookRequest = self.friendRequestsToDisplay[indexPath.row]

    if let cell = tableView.dequeueReusableCellWithIdentifier("RequestCell", forIndexPath: indexPath) as? RequestCell {
        cell.configureCell(friendRequest, isAnIncomingRequest: isAnIncomingRequest)
        return cell

    } else {
        return UITableViewCell()
    }
}
根据断点和一些奇怪的原因,
numberOfSectionsInTableView
numberofrowsinssection
被调用的次数正好是加载的
friendRequests总数的两倍

dequeueReusableCellWithIdentifier
使用断点加载大约需要4秒钟


有人知道滞后的原因是什么吗?

使用时间剖面仪工具分析您的数据app@Paulw11刚刚用时间档案器的结果截图编辑(底部链接)加载自定义字体似乎需要很长时间,但这只是一个小问题guess@Paulw11我如何帮助您确定问题?时间配置文件屏幕截图中显示的所有方法都是系统方法;这与您的代码有什么关联?在您能够确定代码中的时间花在哪里之前,您只是在猜测。