Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 有没有办法将UIAlertController封装到另一个UIViewController中?_Ios_Backwards Compatibility_Uialertcontroller_Forward Compatibility - Fatal编程技术网

Ios 有没有办法将UIAlertController封装到另一个UIViewController中?

Ios 有没有办法将UIAlertController封装到另一个UIViewController中?,ios,backwards-compatibility,uialertcontroller,forward-compatibility,Ios,Backwards Compatibility,Uialertcontroller,Forward Compatibility,我对iOS相当陌生,所以请清楚回答。我一直在尝试将UIAlertController封装在另一个UIViewController中,以替代iOS 8中不推荐的UIActionSheet 这个想法将取代UIActionSheet,它是向后和向前兼容的,例如称之为永生ActionSheet 如果该组件在iOS 8或更高版本中使用,它可以使用UIAlertController,否则它将退回到UIActionSheet。这将使它成为一个向后和向前兼容的操作表,以取代我正在使用的应用程序周围的许多操作表。

我对iOS相当陌生,所以请清楚回答。我一直在尝试将UIAlertController封装在另一个UIViewController中,以替代iOS 8中不推荐的UIActionSheet

这个想法将取代UIActionSheet,它是向后和向前兼容的,例如称之为永生ActionSheet

如果该组件在iOS 8或更高版本中使用,它可以使用UIAlertController,否则它将退回到UIActionSheet。这将使它成为一个向后和向前兼容的操作表,以取代我正在使用的应用程序周围的许多操作表。是的,我需要保持向后兼容性

我已经将其原型化了,但无论出于什么原因,当我展示InhernovationSheet时,UIAlertController视图本身将始终显示在左上角(0,0)。无论我改变中心,它都不会移动

-(void) loadView
{
     UIView * child = nil;
     if ( [UIAlertController class] )
     {
         UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"Make Choice!!" message:@"Choose one!" preferredStyle:UIAlertControllerStyleActionSheet];
         for (UIAlertAction * action in actions ){
             [alertController addAction:action];
         }

         child = alertController.view;
         [self addChildViewController:alertController];
     }

     self.view = [[UIView alloc] init];
     self.view.backgroundColor = [UIColor clearColor];
     [self.view addSubview:child];
}

已经有一个类似的向后兼容包装器,您可能会感兴趣:>UIAlertController视图本身将始终显示在左上角(0,0)。-你有这张照片吗?当然有,@pkamb。编辑问题以显示屏幕截图。我基本上是让UIAlertController创建视图,然后从中添加视图作为我的UIController的子视图。我刚才在这里添加了一个类似的问题:我创建了一个ShowSystemAlert类,用于处理旧版本和新版本的警报。我在这里记录了它。