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我如何帮助您确定问题?时间配置文件屏幕截图中显示的所有方法都是系统方法;这与您的代码有什么关联?在您能够确定代码中的时间花在哪里之前,您只是在猜测。