viewcontroller

How to pass button title to next view controller in Swift

…衆ロ難τιáo~ 提交于 2021-02-10 20:24:40
问题 I have several buttons defined in a loop in viewDidLoad. They are inside a content view, which is in a scroll view. for var i:Int = 0; i < colleges.count; i++ { let collegeButton = UIButton.buttonWithType(UIButtonType.System) as UIButton collegeButton.frame = CGRectMake(0, 0, self.contentView.frame.size.width, 30) collegeButton.center = CGPoint(x: self.contentView.center.x, y: 30 * CGFloat(i) + 30) collegeButton.setTitle(sortedColleges[i], forState: UIControlState.Normal) collegeButton

Passing data between view controllers produces nil [duplicate]

被刻印的时光 ゝ 提交于 2021-02-10 18:18:56
问题 This question already has answers here : EXC_BAD_INSTRUCTION When Passing UICollectionView Cell Data to Different ViewController (2 answers) Closed 3 years ago . I'm a new programmer and struggling with passing data between controllers, I am aware this question is asked in these forums but the uploaded code is much more complex compared to mine and i struggle to understand it so will upload my few lines i've written. I want to allow two players to type their names into my app and then click

Black screen page on apple watch apps with more that one page

孤者浪人 提交于 2021-01-29 09:51:07
问题 Hi I have created a Watch app which has two pages but when I run it on apple watch and do switch between pages after few seconds one page(sometimes page1 and sometimes page2)goes black and It doesn’t show my buttons, labels nothing. But when I run it on simulator there is no problem everything is fine and also before i add second page to the app It was ok on apple watch too 回答1: I had the same issue and it was due to calling crownSequencer.focus() without a corresponding crownSequencer

Change textColor, viewBackground & subview Background

守給你的承諾、 提交于 2021-01-29 09:50:21
问题 I want to change view controllers background color, subviews background color, & text color on condition. For example: There are 2 options (A & B ViewController) on mainViewcontroller. If a user chooses A ViewController then it will follow its color from A to X, Y, Z ViewsControllers till I push, performSegue, or present X, Y, Z View Controllers. If a user chooses B ViewController then it will follow its color from B to X, Y, Z ViewsControllers till I push, performSegue or present X, Y, Z

How can i change the same value between different view controllers?

夙愿已清 提交于 2021-01-28 22:14:34
问题 im very new to swift/programming, so sorry if this is dumb question or sorry if my question isnt clear enough. The yellow label named "Money" has got to be the same value in every viewcontroller, so if the current value is 1000 in the first viewcontroller, its also 1000 in the second viewcontroller. Now i press that button that says "add money 200" and instead of 1000, the yellow label now has 1200. Press the "add money 200" again and i get 1400. Press "add money 400" in the secondVC and now

How to call a uikit viewcontroller method from swiftui view

我只是一个虾纸丫 提交于 2021-01-27 20:39:10
问题 I have looked all over for the answer to this question and can't seem to find it. How can I call a viewController method from swiftUI (e.g. on a button click)? I have a viewcontroller that looks like this: import Player class PlayerViewController: UIViewController { var player = Player() func play() { self.player.play() } } And I have a wrapper that looks like this: import SwiftUI import AVFoundation struct ProjectEditorPlayerBridge: UIViewControllerRepresentable { func makeUIViewController

How to determine whether current view controller is active, and execute code if active

痞子三分冷 提交于 2021-01-07 03:06:26
问题 In my app, there is a ViewController.swift file and a popupViewController.swift file. Inside the app, when I open the popupViewController with storyboard segue as presentModally and then come back from popupViewController to ViewController with the code dismiss() , the methods viewDidLoad, viewWillAppear, viewDidAppear, ViewWillLayoutSubviews etc. nothing works, they execute just once and don't repeat when I go and return back. So, I want to execute the code every time when viewController

How to determine whether current view controller is active, and execute code if active

99封情书 提交于 2021-01-07 02:56:01
问题 In my app, there is a ViewController.swift file and a popupViewController.swift file. Inside the app, when I open the popupViewController with storyboard segue as presentModally and then come back from popupViewController to ViewController with the code dismiss() , the methods viewDidLoad, viewWillAppear, viewDidAppear, ViewWillLayoutSubviews etc. nothing works, they execute just once and don't repeat when I go and return back. So, I want to execute the code every time when viewController

How to determine whether current view controller is active, and execute code if active

邮差的信 提交于 2021-01-07 02:55:45
问题 In my app, there is a ViewController.swift file and a popupViewController.swift file. Inside the app, when I open the popupViewController with storyboard segue as presentModally and then come back from popupViewController to ViewController with the code dismiss() , the methods viewDidLoad, viewWillAppear, viewDidAppear, ViewWillLayoutSubviews etc. nothing works, they execute just once and don't repeat when I go and return back. So, I want to execute the code every time when viewController

MAC OS Xcode Swift 2.2 Fullscreen Mode

我们两清 提交于 2020-12-05 11:27:07
问题 What Swift code will switch the app to fullscreen? I found references with example code for IOS. I am looking for a code which works for a MacOS app. 回答1: One way is to override viewDidAppear in NSViewController : class ViewController : NSViewController { override func viewDidAppear() { let presOptions: NSApplicationPresentationOptions = ([.FullScreen,.AutoHideMenuBar]) let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions : NSNumber(unsignedLong: presOptions.rawValue)] self