转载自:http://xn--vgu7zj1pprm.tw/node/2013-12-02.htm
iOS7有許多改變,尤其是UI,UISwitch在iOS7改變了大小。
iOS7的UISwitch是51x31,而iOS7之前UISwitch是79x27,所以:
UISwitch的位置會有所改變,需要用程式來更改其位置。例如使用center來更改其位置:
pagingEnabled.center = CGPointMake( spacing + self.pagingEnabled.frame.size.width / 2, pagingEnabled.center.y);
找到我的项目中uiswitch之所以那样的原因了,就是因为我写的有问题,有重复创建 然后覆盖,下次应该这样写(把它定义成全局变量)
if (_newSwitch) {
[_newSwitchremoveFromSuperview];
_newSwitch = nil;
}
_newSwitch = [[UISwitchalloc]init];
_newSwitch.frame =rect;
BOOL result = [[NSUserDefaultsstandardUserDefaults]boolForKey:KEYSAVEIMAGETOALBUM];
[_newSwitch setOn:resultanimated:NO];
[_newSwitchaddTarget:selfaction:@selector(switchAction:)forControlEvents:UIControlEventValueChanged];
[cell.contentView addSubview:_newSwitch];
return cell;