How can I put a picture on my keyboard
So I'm working on a custom keyboard in IOS 8
Simple code here
https://github.com/archagon/tasty-imitation-keyboard
I want to know if I can change the background of the keyboard!
Can I put a picture on the background of the keyboard by fixing the number of images defined Rausch and simply just choose by pressing ...?
I try to do it in this way:
In the window Main.storyboard
I have a view named - Hosting Controller App View
Class: HostingAppViewController
I added another view named -Catboard Banner
Class: CatboardBanner
I added a button in the view - Hosting Controller App View
To go to view - Catboard Banner
Then I added a button to go back to view - Hosting Controller App View
My question is this:
When I try to add a second button within view - Catboard Banner and I want this button will put a picture on the background of my keyboard by pressing the button
As soon as I press my app crashes
Is there a way to do something to control my keyboard out the window view - Catboard Banner
ViewController.swift
import UIKit
class HostingAppViewController: UIViewController {
KeyboardViewController.swift
import UIKit
import AudioToolbox
import AVFoundation
let metrics: [String:Double] = [
"topBanner": 30
]
class KeyboardViewController: UIInputViewController {
CatboardBanner.swift
import UIKit
class CatboardBanner: ExtraView {
Related
I'm currently working on rewriting a VoIP app from UIKit to SwiftUI. In the UIKit version, we have an active call screen with a button that when tapped, closes the active call screen and lets you interact with the app. Tapping this button also adds a view to the UINavigationController, basically covers most of the navigation view and when tapped, returns the user back to the active call screen.
I'm experimenting with different ideas in SwiftUI, but haven't hit on any solid ideas yet and wanted to see if the community had any ideas for accomplishing this.
Here's a sample of what the UIKit code:
class MainNavController: UINavigationController {
func showActiveCallBar() {
...
let activeCallBarView = ...
...
view.addSubview(activeCallBarView)
}
}
Here's a gif of what happens when we switch back and forth, sorry, couldn't show the whole app. You can see the whole upper portion of the Navigation View gets covered.
Thank you!
In SwiftUI, we would accomplish something like this with an #State variable, which would track wether we want to show the active call bar.
When your state variable changes, your SwiftUI view will be updated and the active call bar will be shown or hidden. It might look something like this.
struct PlayButton: View {
#State private var showActiveCallBar: Bool = false
var body: some View {
if (showActiveCallBar) {
ActiveCallBarView()
}
// ... Other Views
}
}
The SwiftUI documentation of State has more helpful information, and the SwiftUI docs generally are quite helpful in this regard. You could start with the SwiftUI tutorials https://developer.apple.com/tutorials/swiftui
I have a project which has been entirely built using UIKit. We are now trying to slowly introduce SwiftUI for any new UI views that we build into the app.
So y current dilemma is that we have a UIViewController which contains a view with a button that needs to present some kind of a pop-up view containing a list of notifications (which I plan to build using List in SwiftUI. For context, here is how the current view looks (built using UIKit). User would then tap on 'Show me...' and be taken to the new SwiftUI view.
So initially I just tried like this:
#objc func showNotifications() {
let controller = UIHostingController(rootView: NotificationContentView())
self.present(controller, animated: true, completion: nil)
}
This obviously presents a modal view which is great, but I want to be able to control the size of this view. The notification screen should be fairly narrow, not virtually full screen.
I wonder how I might go about implementing this.
OS: MacOS
language: Swift 4+
What I want
I want to show a simple custom modal view from my main window. This custom modal view I created in a separate .xib file with belonging NSWindowController class.
In Xcode I added a new file --> CocoaClass --> Subclass of NSWindowController --> Checkmarked "Also create XIB file for user interface"
I than added a button and generated an action handler that simply prints text on the debug console. This to test whether the button press is correctly handled or not.
To show the modal view from my main window I have the following code executed when a button has pressed:
let modal = SimpleModal(windowNibName: "SimpleModal")
self.view.window?.beginSheet(modal.window!, completionHandler: { response in
print("Finished device selection")
})
This does show the view, but not as a modal view. It simply shows the view next to my main window and the modal view also doesn't react on mouse click events, when I click on the button in the modal view.
I don't know how to get this right, so if you know how to do this, please answer me.
NOTE:
When modal view shows up, the main window should be unresponsive until the user dismisses the modal view. It's like moving the focus from main window to the modal view.
The source of my demo project:
OSXModalView
You have to remove the Visible At Launch flag in the attribute inspector of your window object in SimpleModal.xib. Otherwise your code works.
Im developing an osx application in Swift 4 to be displayed in the menu bar and call a popover when clicked to display a number of different views.
My structure in Storyboard is:
NSView > Container View > Tab View
This lets me maintain a top menu bar while being able to change between tabs.
I have hidden the buttons in the NSTabView and have managed to change between views on load using the following code:
import Cocoa
class TabViewController: NSTabViewController {
#IBOutlet weak var theFirstTab: NSTabViewItem!
override func viewDidLoad() {
super.viewDidLoad()
changeTab()
}
func changeTab() {
let theTabView = theFirstTab.tabView
theTabView?.selectTabViewItem(at: 3)
}
}
When I start my application this loads the 3rd tab programatically which is great!
What I want to do however is create my own menu in the parent ViewController to call this function so that the tabs change within the container.
Is it possible to call this function from the parent somehow?
Ive searched all over for a solution to this problem and am so close but hopefully someone here can help me. I can add pictures of my storyboard if this is not clear enough?
Thanks in advance.
I have following problem:
I try to build a small MenuBar App for MacOs. It is xib based and the main app is a MainMenu. From one of the menuItems I try to open a new NSWindow. I made a SecondViewController.swift with its generated SecondViewController.xib.
Simple View with one button:
View of NSWindow as xib
SecondViewController.swift
Source Code
The button title changes to "ROFL", but when the button is pressed nothing happens. Cann someone explain this to me?
Here the controller is created:
Init code of Controller