viewcontroller

IBOutlets on second view controller help on swift

允我心安 提交于 2019-12-13 22:12:49
问题 On my first view controller I had no problem creating IBOutlets and Actions, but when I made another view controller, I couldn't make an IBOutlet. There was no blue line when I control dragged it and I couldn't make an IBOutlet and then connect it up either. The first view controller still works. Is it possible to make IBOutlets on two different view controller? 回答1: Your view controller must have a custom class file assigned to it in the identity inspector in InterfaceBuilder: Then select

I managed to segue to a blank view controller. How do I segue back?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 17:14:17
问题 // // ViewController.swift // FunFacts // // Created by Alex Macleod on 4/10/14. // Copyright (c) 2014 Alex Macleod. All rights reserved. // import UIKit class ViewController: UIViewController { @IBOutlet weak var funFactLabel: UILabel! @IBOutlet weak var funFactButton: UIButton! @IBOutlet weak var swipeView: UIView! // let swipeRec = UISwipeGestureRecognizer() let factBook = FactBook() let colorWheel = ColorWheel() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup

Application tried to present modally an active controller ios

瘦欲@ 提交于 2019-12-13 13:12:47
问题 I was trying to set the ViewController with a parent view controller before it shows show that it can provide call backs, I done this using PrepareForSegue - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"newQuarter"]) { [segue.destinationViewController setParentViewController:self]; } } It crashed giving me the error message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to

How to change dynamically the xib of a UIVIewController

别来无恙 提交于 2019-12-13 12:33:48
问题 I have an UIVIewController "controller1" for instance. This controller is instanciated with initWithNibName... with "file1.xib". I want to dynamically change the xib file of my "controller1" to "file2.xib" To resume : "controller1" <-> "file1.xib" and I want to dynamically have : "controler1" <-> "file2.xib" How can I do this ? Hope I was clear. 回答1: When you want to change views in a UIViewController just just use this code: NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"file2"

iOS Objective-C App crashing for unusual reason

ぐ巨炮叔叔 提交于 2019-12-13 10:27:32
问题 My app is crashing with the error code: SIGABRT. Ive done a ton of research and none of the "SIGABRT solutions" have ever helped. This is what is in the console after app crashes on the iOS Simulator: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ViewController" nib but the view outlet was not set.' If anyone can help me that would be great! 回答1: Open up your ViewController's xib file, right

Movie Player in Swift

一曲冷凌霜 提交于 2019-12-13 09:31:39
问题 I'm doing simple movie player in swift. I have player in ViewController like this. and i want it like this. Here's code import UIKit import MediaPlayer class DetailViewController: UIViewController { var moviePlayer:MPMoviePlayerController! override func viewDidLoad() { super.viewDidLoad() var url:NSURL = NSURL(string: "http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v") moviePlayer = MPMoviePlayerController(contentURL: url) moviePlayer.view.frame = CGRect(x: 16, y: -100, width: 600,

how to pass data between these two view controllers in swift

↘锁芯ラ 提交于 2019-12-13 08:59:35
问题 in this case i have tabbar controller and navigation controller between the two VC,which means firstly i want to pass data between the first VC and the tabbar controller, and secondly i want to pass the same data from the tab bar controller to navigation controller , and finnally to the last VC,i searched for example in the net but i didn't find anything useful. please can u help me pass data between these two viewcontrollers ,any example will be great, thaank's. 回答1: Set an identifier to the

From Thirdviewcontroller to FirstViewcontroller

孤街醉人 提交于 2019-12-13 07:50:54
问题 I have two navigationviewcontroller in my story board. Firstviewcontroller linked to firstnavigationcontroller. ThirdViewcontroller linked to second navigationcontroller. Then I want to know how to go from thirdviewcontroller to firstviewcontroller. 回答1: There are a couple ways to return to FirstViewController from ThirdViewController: [UINavigationController popToRootViewControllerAnimated:] method Set up a storyboard unwind segue This post has more detailed examples. 来源: https:/

Reloading view controller when navigation bar back button is pressed in swift 2

限于喜欢 提交于 2019-12-13 06:49:44
问题 I have three view controllers which in the third one I have a picker view which it store data into core data, and when I press navigation bar back button I want second view controller to refresh it's labels from core data, but I don't know how Any suggestion ? 回答1: Use NSFetchRequest() method in viewWillAppear() method in second view controller 来源: https://stackoverflow.com/questions/35578699/reloading-view-controller-when-navigation-bar-back-button-is-pressed-in-swift-2

Run method when viewcontroller is accessed from another vc being dismissed

被刻印的时光 ゝ 提交于 2019-12-13 05:38:54
问题 Let's say I have my initial vc called VC1, then I have a second one called VC2. VC1 has a segue to VC2, on VC2 there is a button that will dismiss VC2 and then show VC1. Once VC1 loads I want to run a method but I can't do that in view did load so where can I do it? [VC1] -> [VC2] 回答1: You can use a delegate method to achieve this. In the method you call to dismiss VC2 call the delegate. You can implement this delegate in VC1. 回答2: You can also try Unwind Segue for dismissing the VC2 and call