我正在使用 UIActivity 指示器作为 UItableviewfooter, 我的代码显示在这里
spinner = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.frame=CGRectMake(0, 0, 310, 44);
[spinner startAnimating];
self.myTableView.tableFooterView=spinner;
这在模拟器中运行良好,但当我在设备中运行它时,事件指示器似乎根据单元尺寸在两个轴上拉伸(stretch)。
最佳答案
spinner.frame=CGRectMake(0, 0, 310, 44);
可能是因为您将事件微调器的宽度设置为 310 磅。相反,将其设置为 44(使框架为正方形),并调整 x 原点参数使其居中。
目前我无法对此进行测试,但它可能采用以下形式:
CGFloat activityWidth = 44;
CGFloat activityHeight = 44;
CGFloat tableFooterViewWidth = self.myTableView.tableFooterView.frame.size.width;
spinner.frame=CGRectMake(tableFooterViewWidth - (activityWidth/2),
0,
activityWidth,
activityHeight);
关于iphone - UIActivity 指示器用作 Uitableview 页脚时在设备中显示拉伸(stretch)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13050662/