在表视图中呈现模态视图控制器

时间:2013-09-23 10:00:31

标签: ios uinavigationcontroller presentmodalviewcontroller

美好的一天,每个人。

我在表视图控制器中有这个代码:

    else if (editingStyle == UITableViewCellEditingStyleInsert) {


        if([[UIScreen mainScreen] bounds].size.height == 568)
        {
            citySearch = [[CitySearch alloc] initWithNibName:@"CitySearchIphone5" bundle:nil];

        }
        else
        {
            citySearch = [[CitySearch alloc] initWithNibName:@"CitySearch" bundle:nil];
        }
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:citySearch];
        [self presentModalViewController:navController animated:YES];

所以,当它出现时,我看到了视图,即超越边界,Xcode写了这个

  

不建议在分离的视图控制器上显示视图控制器

如何解决?

2 个答案:

答案 0 :(得分:1)

presentModalViewController:animated:已在iOS 6.0中弃用。请改用presentViewController:animated:completion:

[self presentViewController:navController animated:YES completion:nil];

Apple Documentation

答案 1 :(得分:-1)

 MACommentsViewController *obj_AboutVC;
 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
 {
    if (IS_IPHONE_5)
    {
        obj_AboutVC = [[MACommentsViewController alloc]         initWithNibName:@"MACommentsViewController" bundle:nil];
    }
    else
    {
        obj_AboutVC = [[MACommentsViewController alloc] initWithNibName:@"MACommentsViewController_iPhone4" bundle:nil];
    }
}

[self presentViewController:obj_AboutVC animated:YES completion:nil];