草庐IT

MX_Controller

全部标签

ios - 如何在不重复代码的情况下在所有 Controller 中显示警报?

我想编写一个函数alert()并运行它。但我想在不重复代码的情况下在任何Controller中显示此警报。例如:我有Presence.swift类,这里我有一些条件,如:ifmyVar==1{//JustforpresentingrunMyAlert()}当myVar==1用户处于后台时,无论他身在何处,在哪个屏幕上,他都会在屏幕上收到警报。如何在不重复我的代码的情况下做到这一点?我试图在AppDelegate中将其制作为:funcalert(title:String,message:String,buttonTitle:String,window:UIWindow){letalert

ios - 应用程序试图在发送文本时在目标上呈现一个 nil 模态视图 Controller

我正在尝试发送一条短信并像这样设置Controller,但我收到一条错误消息'NSInvalidArgumentException',reason:'Applicationtriedtopresentanilmodalviewcontrollerontarget.'我已确保在我的Storyboard中将其连接到TextMessageController,因此我不太确定是什么导致了崩溃。classTextMessageController:UIViewController,MFMessageComposeViewControllerDelegate{varphone:String?ove

swift - 如何在 swift3 中更改导航 Controller 上的后退按钮标题?

我想在swift3中将后退按钮的标题更改为任何名称。我尝试了很多方法,但没有一种对我有用。self.navigationItem.backBarButtonItem?.title="Title"self.navigationController?.navigationItem.backBarButtonItem?.title="Title"仅供引用,我在appdelegate中编写了以下代码。letbackImage:UIImage=UIImage(named:"backArrow")!UINavigationBar.appearance().barTintColor=UIColor(

ios - 如何返回到不同 Storyboard的上一个 View Controller ?

我有2个StoryboardA和B。StoryboardA有多个ViewController。在一些用户操作之后,我从StoryboardA切换到StoryboardB。如何通过单击后退按钮返回到之前的StoryboardA并返回到我最初来自的同一ViewController。我不能按照下面给出的那样做,因为我不会有A的旧导航堆栈。letstoryboard=UIStoryboard(name:"A",bundle:nil)letvc=storyboard.instantiateInitialViewController()asUIViewController!presentViewC

ios - Swift 无法从上到下呈现 View Controller

在我的应用程序中,我必须从上到下呈现屏幕,我已经尝试使用下面的代码提供相同的正常呈现风格。letscreen=self.storyboard?.instantiateViewController(withIdentifier:"Screen1p5")as?Screen1p5lettransition=CATransition()transition.duration=0.5transition.type=kCATransitionPushtransition.subtype=kCATransitionFromTopview.window!.layer.add(transition,fo

ios - 如何将 UIPickerView Controller 中的图像或视频保存到文档目录?

处理选定的图像或视频:funcimagePickerController(picker:UIImagePickerController,didFinishPickingMediaWithInfoinfo:[String:AnyObject]){print("ok")ifletimage=info[UIImagePickerControllerOriginalImage]as?UIImage{//whattodotosavethatimage}else{//howtogetthevideoandsave}}保存到文档目录:letpath=try!NSFileManager.default

ios - 呈现 UIImagePickerController 时如何获取顶 View Controller ?

有时我会显示UIImagePickerViewController。呈现后,我调用我的函数:UIStoryboard.topViewController():extensionUIStoryboard{classfunctopViewController(base:UIViewController?=UIApplication.sharedApplication().keyWindow?.rootViewController)->UIViewController?{ifletnav=baseas?UINavigationController{returntopViewControlle

ios - 使用 NSUserDefaults 保存 ViewController 页面上的触摸按钮,该按钮与导航 Controller 相关

所以我在ViewController上有4个按钮,它是应用程序的初始ViewController。每个按钮都“显示”到不同的导航Controller(连接到UITableView)。我的目标是以某种方式保存使用NSUserDefaults触摸的按钮,并跳过ViewController并直接转到选定的导航Controller,每次打开应用程序时!这可能吗?我正在用Swift写这个这是我的AppDelegate(关于“varbuttonSelected”的警告):importUIKit@UIApplicationMainclassAppDelegate:UIResponder,UIAppl

ios - 导航 Controller 和容器 View 之间的通信

ParentViewController_________________||||||NavigationCont.|_________________|_________________|||||||||ContainerView|-->||-->ChildViewControllers|||||_________________||_________________|我的应用有一个导航结构,由一个父ViewController和一个包含导航Controller(及其subviewController)的容器组成。问题是在这些subviewController的初始化过程中,我想传递

ios - View Controller 需要时间来加载

我有2个ViewController。查看ControllerA和查看ControllerB。当我单击ViewControllerA上的按钮时,它会将我推送到ViewControllerB。但是当我单击ViewControllerA上的按钮时,加载ViewControllerB需要时间并在页面上显示一些延迟。我在ViewControllerB上使用了3个CollectionView。 最佳答案 在点击按钮时调用BViewController时使用它这是苹果的官方文件https://developer.apple.com/librar