将子视图添加到滚动视图会挂起我的屏幕

时间:2014-11-13 04:16:07

标签: ios

我添加了一个scrollview来查看使用xib自动布局,我已经放置了uiswitch。如果我选择UISwitch我会以编程方式向scrollview添加标签和文本字段,这会挂起我的屏幕并且无法执行任何操作。这个错误发生在iPhone5s ..它工作正常iPhone 4和iPad

_hosStartDateLbl.frame=CGRectMake(_birthLbl.frame.origin.x, _birthLbl.frame.origin.y+_birthLbl.frame.size.height+15,  [_hosStartDateLbl.text sizeWithFont:_hosStartDateLbl.font].width, 17);//birthLbl is in xib

[_hosStartDateLbl sizeToFit];

  _hosStartDateTxt.frame=CGRectMake(_hosStartDateLbl.frame.origin.x, _hosStartDateLbl.frame.origin.y+_hosStartDateLbl.frame.size.height+5, eventStartTxt.frame.size.width,eventStartTxt.frame.size.height);//eventStartTxt in xib

[self.scroll addSubview:_hosStartDateLbl];
            _hosStartDateTxt.delegate=self;
[self.scroll addSubview:_hosStartDateTxt];

 scroll.contentSize = CGSizeMake(scroll.frame.size.width, _hosStartDateTxt.frame.origin.y+_hosStartDateTxt.frame.size.height+160);

0 个答案:

没有答案
相关问题