我试着做一些很简单的事情。根据设备的大小或方向,为音量设置一个可变宽度的滑块。
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpVolumeView];
}
- (void) setUpVolumeView {
// Volume control
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:self.myBoxForVolume.bounds];
[self.myBoxForVolume addSubview:volumeView];
//[volumeView sizeToFit];
}在我的故事板中,我将myBoxForVolume设置为与设备视图的左界有一定距离,与设备视图的右界有一定距离。我希望volumeView具有与myBoxForVolume相同的宽度(请记住myBoxForVolume可以改变大小),但由于某些原因,我无法建立具有正确界限的volumeView。
发布于 2015-03-27 05:20:45
缺少一行代码,所有这些都会发生。
volumeView.autoresizingMask = UIViewAutoresizingFlexibleWidth;在setUpVolumeView方法中添加这样的行可以解决调整大小的问题。
https://stackoverflow.com/questions/28893544
复制相似问题