将uiview作为子视图添加到主视图
我想为小尺寸添加UIView
作为现有视图的子视图。将uiview作为子视图添加到主视图
我有这是主视图笔尖名字推了UIViewController
,我想创建的UIView
对象或Alloc它的尺寸与在视图 - 控制的viewDidLoad
methoad下面的代码
UIView *view = [[UIView alloc] init];
但这个想法是不是暗示在UIView
的alloc和抛出一个错误,如果我用力的类型和运行
请帮我这个
要添加的东西(而重要的),上述问题的答案;
CGRect frame = CGRectMake(x, y, width, height); // Replacing with your dimensions
UIView *view = [[UIView alloc] initWithFrame:frame];
然后,要真正地把它添加到上海华盈(假设的观点是self.view)
[self.view addSubview:view];
UIView *view = [[UIView alloc] init];
'的UIView *视= [[UIView的页头] INIT]' 你错过了一个支架。 – marramgrass 2009-09-15 12:33:39
谢谢!键入失败 – CVertex 2009-09-15 12:36:15
UIView的需要被alloc'ed并与框架init'ed:
CGRect frame = CGRectMake(x, y, width, height); // Replacing with your dimensions
UIView *view = [[UIView alloc] initWithFrame:frame];
我想在我的viewcontroller类的viewdidload方法相同,但xcode不建议在uiview上的分配,如果我强制复制粘贴此代码的视图,如果不是作为subview添加到self.view – Gani 2009-09-16 09:17:52
我是尝试在我的viewcontroller类的viewdidload方法相同,但Xcode不建议在uiview上的分配,如果我强制复制粘贴此代码视图,如果不被添加为subview作为self.view – Gani 2009-09-16 09:18:30
哇谢谢你... – Morkrom 2013-07-22 21:06:46