Tag: uiviewcontroller

我怎样才能解除一个模式segue,然后执行push segue到新的视图控制器

我试图从navigation controller执行一个push segue ,解散之前在navigation controller上显示的modal 。 内部模态( UIViewController ): func textFieldShouldReturn(textField: UITextField) -> Bool { var searchNav = SearchNavigationController() self.dismissViewControllerAnimated(true, completion: {searchNav.goToNextView()}) return true } 在SearchNavigationController里面: func goToNextView() { performSegueWithIdentifier("searchNavigationToNextView", sender: self) } 问题是,当我打回来,我得到这个错误: 终止应用程序由于未捕获的exception“NSInvalidArgumentException”,原因:“Receiver()没有与标识符searchNavigationToNextView” segue出现在我的storyboard ,从UINavigationController转到next view 。 编辑:试过这个,在_SendSelectViewController中声明_sender var _sender = self并没有工作。 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "searchNavigationToSingleSearch" […]

iOS Storyboard:ViewController之外和场景之上的视图(First Responder和Exit框之间)

我很难理解为什么你可以把UIViews放在故事板上的UIViewController之外,以及它的用例是什么。 例如,在故事板上,我可以添加UIToolbar , UIAcitivtyIndicator和UIProgressView ,在UIViewController之外。 这是否意味着有一种方法可以引用UIViewController之外的那些Views ,并可能以某种方式以编程方式显示它们,或者像使用ContainerView一样embedded这些Views ?

自动布局中的比例距离限制

我无法通过> iOS6中的自动布局来实现所需的布局布局。 我有UIView1和UIView3固定到父视图(相应地与TopSpaceToSuperview,BottomSpaceToSuperView和FixedHeight),他们的行为与父视图更改高度时的预期。 我应该在IB中为UIView2指定哪些约束条件,如果我希望它在父视图改变高度时保持与其同胞(UIView1和UIView3)相同的比例距离? (如图中所示)

如何使用UIImagePickerController呈现ViewController

我试图展示一个ImagePicker ,并且在用户select一个图像之后,呈现一个图像编辑ViewController ,用户可以在其中操作图像,然后将编辑后的图像发送回原来的ViewController 。 题: 是否有一个标准或最佳实践方法,从初始ViewControlle开始,然后在另一个ViewController之后呈现ImagePicker进行图像编辑,然后将其全部显示在初始ViewController中,同时使转换看起来无缝? 下面的试用3中的build议是一个好的实践方法还是有一个更好的例子来说明如何实现这一点? 试试1。 我最初的想法是通过下面的代码以编程方式呈现ImagePicker ,然后在select图像之后进行图像编辑ViewController 。 但是这种方法似乎并不正确。 拾取图像后,我似乎无法使ImagePicker正确地继续到ViewController 。 (编辑ViewController显示了一堆“意外地发现零,而解包可选值”错误)。 let imagePicker = MyImagePickerController() imagePicker.delegate = self imagePicker.sourceType = .PhotoLibrary imagePicker.allowsEditing = false imagePicker.modalTransitionStyle = UIModalTransitionStyle.CoverVertical self.presentViewController(imagePicker, animated: true, completion: nil) 试试2。 我的第二个尝试是呈现一个图像编辑ViewController作为一个隐藏/透明之后立即加载的ImagePicker ,但这会导致一些空的背景闪烁。 试试3。 所以我遇到了这个build议,这是我第二次尝试使用窗口背景的变体,以显示当前ViewController的图像,这似乎是可能的。 http://xissburg.com/presenting-multiple-modal-view-controllers-at-once/ 试试4。 我的另一个想法是创build一个单独的ViewController , ImagePicker处理一个ImagePicker ,然后通过接口构build器中的segues连接每个ViewController 。

创build一个没有笔尖的视图控制器

在AppDelegate中,我想创build一个UIViewController子类并添加它的视图。 viw本身将在代码中指定 – 没有笔尖。 基于苹果文档,我应该使用 initWithNibName:nil bundle:nil]; 然后在控制器的loadView,我添加我的子视图等 但是,下面的下面的testing代码不适用于我。 我模拟了Apple的PageControl演示中的AppDelegate代码,只是因为我的应用程序将实现类似的结构(特别是基本控制器来pipe理分页滚动视图,以及其他控制器的数组来构build页面)。 但我怀疑我的AppDelegate代码是问题,因为日志loggingcertificateinitWithNibName ::和loadView都触发。 下面的应用程序运行,但屏幕是空白的。 我期待带有标签的绿色景观。 AppDelegate中 – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ScrollerController *controller = [[ScrollerController alloc] initWithNibName:nil bundle:nil]; [self.window addSubview:controller.view]; [self.window makeKeyAndVisible]; return YES; } ScrollerController (UIViewController子类) – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } […]

旋转UIView – willRotateToInterfaceOrientation不被调用

我试图自动控制一个视图,我有这里解释相同的问题: willRotateToInterfaceOrientation没有被调用 。 即使我实现了shouldAutorotateToInterfaceOrientation并返回YES,在我实现的每个UIViewController子类中; willRotateToInterfaceOrientation没有被调用。 也许有人可以告诉我我错过了什么。 我有以下视图控制器结构(我希望这是清楚的..): NavigationController (Programatically) -with root > TabBarController (Programatically) -with tab item > NavigationController (Programatically) -with root > UITableViewController (a Subclass) -pushed to navigator controller > UIViewController (a Subclass). 我希望有一个人可以帮助我。 提前致谢!

从导航控制器中popup多个视图

我有一个应用程序,它的rootview是一个菜单,用户通过select一个加载另一个子视图的单元格来设置一个search查询的4个tableviews,所以基本的结构看起来像这样 Root View – Parent View (search view) –Sub View (user selects variables here to fill search parameters of the parent view 但其中一个父视图search参数要求另一个子视图被推到导航堆栈,所以它看起来像 Root View – Parent View (search view) –Sub View (user selects variables here to fill search parameters of the parent view —Sub View (related values to the previous subview ie Model / […]

我如何完全重新加载视图,以便viewDidLoad再次运行?

我想重新加载我的视图,以便viewDidLoad重做所有的工作。 我怎么能在Swift中做到这一点?

iOS 7 – 隐藏子视图控制器上的状态栏

UIApplication.SharedApplication.SetStatusBarHidden (MonoTouch代码,也适用于Obj-C)完成iOS 6的工作,但对于iOS 7,我们必须: 在视图控制器上调用SetNeedsStatusBarAppearanceUpdate () (例如:显示全屏图像的视图控制器) 在同一视图控制器上覆盖PrefersStatusBarHidden () 。 然而,上面提到的视图控制器embedded在导航栏中,导航栏也embedded在滑出菜单中。 即使使用AddChildViewController()将所有embedded式视图控制器添加到层次结构中,尝试更新子视图控制器中的状态栏也不起作用。 有任何想法吗? 编辑 Window.RootViewController (Menu) |___ ViewControllerA (Navigation Bar) |___ ViewControllerB (Actual View controller) ViewControllerB想要隐藏/显示状态栏

shouldAutorotate没有调用视图控制器

我有一个简单的应用程序组成的单个视图控制器。 我开始使用Xcode 7 GM Single View Application模板,但是删除了主要的故事板,并设置了我的视图控制器,如下所示: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { let vc = ViewController() window = UIWindow(frame: UIScreen.mainScreen().bounds) window!.rootViewController = vc window!.makeKeyAndVisible() return true } 在我的信息plist中,我具有在支持的界面方向下指定的所有方向,并且该应用程序在iPad上旋转到所有方向。 但是,在我的简单视图控制器中,shouldAutorotate shouldAutorotate()和supportedInterfaceOrientations()方法从不会被调用。 这是一个问题,因为我正在尝试启用和禁用自动旋转的UI控件。 有什么可以阻止这些方法被称为? 这里的示例项目(需要Swift 2) 非UINavigationController