简体   繁体   English

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

[英]Presenting modal view controller in Table View

Good day, everyone. 今天是个好日子。

I have this code in table view controller: 我在表视图控制器中有这个代码:

    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];

so, when it is presented i see view, that is going over bounds and Xcode write this 因此,当它呈现时,我看到视图,这是超越边界,Xcode写这个

Presenting view controllers on detached view controllers is discouraged 不鼓励在分离的视图控制器上呈现视图控制器

how to solve it? 怎么解决?

presentModalViewController:animated: is deprecated in iOS 6.0 . presentModalViewController:animated:iOS 6.0已弃用。 Use presentViewController:animated:completion: instead. 使用presentViewController:animated:completion:而不是。

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

Apple Documentation Apple文档

 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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM