我创建三个按钮和一个UITextView的动态,但是当我运行程序它不是我的屏幕我的按钮和textview不显示在iOS屏幕上?
这是我的代码来创建动态按钮及TextView的
-(void)getSmsdisplay
{
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen]
applicationFrame]];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UITextView *textview=[[UITextView alloc]init];
[button setTitle:@"Comment" forState:UIControlStateNormal];
[button1 setTitle:@"Share" forState:UIControlStateNormal];
[button1 setTitle:@"Like" forState:UIControlStateNormal];
//listen for clicks
[button addTarget:self
action:@selector(btncomment:)forControlEvents:UIControlEventTouchUpInside];
[button1 addTarget:self
action:@selector(btnShare:)forControlEvents:UIControlEventTouchUpInside];
[button2 addTarget:self
action:@selector(Like:)forControlEvents:UIControlEventTouchUpInside];
smsdata *data=[[smsdata alloc]init];
[textview setText:data.Data];
[self.view addSubview:textview];
//add the button to the view
[self.view addSubview:button];
[self.view addSubview:button1];
[self.view addSubview:button2];
}
您重新分配self.view到另一个,这是不添加任何其他子视图。 – ZeMoon 2014-10-29 07:48:19