@property (weak, nonatomic) IBOutlet UIButton *btn;
-(IBAction)delete1{//移除控件[self.myTitle removeFromSuperview];}
NSUnknownKeyException', reason:
[0x7fdf7048b200> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key
解决办法:删除多余的连线
'NSInvalidArgumentException', reason:
'-[ViewController delete2]:
unrecognized selector sent to instance
NSLog(@"%@",self.greenView.superview);
NSLog(@"%@",self.greenView.subviews);
NSLog(@"%lu",self.view.subviews.count);
-(void)viewDidAppear:(BOOL)animated{
NSLog(@"%@",self.view.superview);
}
//实例化一个switch
UISwitch *sw1 = [[UISwitch alloc] init];
//在yellowView中添加uiBtn
[self.yellowView addSubview:sw1];
[self.myTitle removeFromSuperview];
UIView *buleView = [[UIView alloc] init];
//CGRectMake(x, y, w, h)
buleView.frame = CGRectMake(100, 100, 100, 100);
buleView.bounds = CGRectMake(0, 0, 300, 100)
buleView.center =
CGPointMake(self.view.frame.size.width * 0.5,
self.view.frame.size.height *0.5);