簡體   English   中英

推式視圖控制器不能覆蓋整個屏幕

[英]Pushed view controller does not cover entire screen

我創建了一個應用程序,該應用程序以表格視圖顯示設備中的聯系人,當我單擊一行時,它將在另一個視圖上顯示該聯系人的詳細信息。 這是情節提要的樣子: 在此處輸入圖片說明

在我的didSelectRowAtIndexPath中,我有以下代碼:

NewViewController *WVC = [self.storyboard instantiateViewControllerWithIdentifier:@"NewViewController"];
[self.navigationController pushViewController:WVC animated:YES];

當我運行該應用程序時,該應用程序如下所示:

在此處輸入圖片說明

但是,當我單擊一行時,將顯示詳細信息,但是像這樣:

在此處輸入圖片說明

有人可以讓我知道我要去哪里了,謝謝。

NewViewController.m中的代碼

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
 nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, 300, 20)];

 mylabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 125, 300 , 20)];

[nameLabel setText:@"Name :"];
[mylabel setText:_LabelText];
[self.view addSubview:nameLabel];
[self.view addSubview:mylabel];

myPhonelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 175, 300, 20)];
[myPhonelabel setText:@"Contact Number :"];
PhoneLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 200, 300, 20)];
[PhoneLabel setText:_phoneNumber];
[self.view addSubview:myPhonelabel];
[self.view addSubview:PhoneLabel];

myEmailLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 240, 300, 20)];
[myEmailLabel setText:@"Email ID :"];
EmailLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 265, 300, 20)];
[EmailLabel setText:_emailId];
[self.view addSubview:myEmailLabel];
[self.view addSubview:EmailLabel];

myBdayLabel =[[UILabel alloc]initWithFrame:CGRectMake(10, 315, 300, 20)];
[myBdayLabel setText:@"Date Of Birth :"];
BdayLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 335, 300, 20)];
[BdayLabel setText:_birthDate];
[self.view addSubview:myBdayLabel];
[self.view addSubview:BdayLabel];

myButton = [[UIButton alloc]initWithFrame:CGRectMake(10, 30, 300, 30)];
[myButton setTitle:@"Contact Details" forState:UIControlStateNormal];
[myButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
myButton.backgroundColor = [UIColor colorWithRed:0xBD/255.0 green:0xBE/255.0 blue:0xC2/255.0 alpha:1];
myButton.layer.cornerRadius = 10;
myButton.clipsToBounds = YES;
[self.view addSubview:myButton];
}

編輯:(答案)很多頭撞和拉頭發后,通過更換解決了問題

NewViewController *WVC = [self.storyboard instantiateViewControllerWithIdentifier:@"NewViewController"];

NewViewController *WVC = [[NewViewController alloc] init];

老實說,我不知道為什么前一個沒有用。

如果您不需要導航欄,請使用隱藏它

[self.navigationController setNavigationBarHidden:YES];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM