我創建三個按鈕和一個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