I would like to use one of these two cocoapods, https://github.com/graycampbell/GCCalendar, and https://github.com/n8armstrong/CalendarView
I installed with pod install that went great. But when it comes to implementation I don't get it.
For GCCalendar it says "Create a subclass of GCCalendarViewController" and when I do that my Xcode turns red from errors. CalendarView docs say to use #IBOutlet weak var calendar: CalendarView! but when I do that I get errors. CalendarView! doesn't exist.
Can somebody explain what should I do to use CalendarView (I like this more). What should I do first in Xcode after installing pods?
Here is what I get:
Sometime Xcode can not see your pod after you install it in Swift. : (
You can fix issue by press Cmd+B for Build Project after you install Pod.
You forgot to import your library above your ViewController, so Xcode doesn't understand CalendarView
let import it:
import CalendarView
then build project to notify Xcode understand that you have just imported it :).
then initialize CalendarView inside your ViewController with it's frame, like so:
let calendar = CalendarView(frame: CGRectMake(0, 0, CGRectGetWidth(view.frame), 320))
view.addSubview(calendar)
if you want to use #IBOutlet weak var calendar: CalendarView!
You need to drag a UIView to your storyboard, then set it's class is CalendarView, then reference it to your IBOutlet. Hope this help you.
I manage to solve this on my own. I'll post an answer in case somebody else sucks here.
In my case, CalendarView.bundle was not present in .../Build/Products/Debug-iphonesimulator/CalendarView/
So I cp -r from /Library/Developer/Xcode/DerivedData/yourapp/Build/Products/Debug-iphonesimulator/CalendarView/CalendarView/CalendarView.bundle
This works.
Related
I am interested in being able to type LaTeX to get formatted Math Output in my macOS projects. I have tried using the famous iosMath CocoaPod Library and also seen its working from their official examples Repository on GitHub. I am using Xcode 10, Swift 4.2 on macOS Mojave (10.14). Using the guidance given on the reply of this Question I was able to successfully incorporate the library and make it render Mathematical Text using latex in any iOS projects successfully. But it is giving great conflicts and problems in macOS. After Installing the CocoaPod in my own project successfully I tried to follow the paradigm given in their official macOS Example with several trials and errors but all resulting in failure.
I am describing whatever I tried as following:
As we can see, the example projects have used XIBs instead of Storyboards but when trying out the same code and mechanisms on iOS in Storyboards it works just fine.
As per guidance in their example projects I have tried Using a Custom View both on iOS and macOS (i.e. UIView and NSView respectively) and attached that custom view to the custom class MTMathUILabel in the Identity Inspector in Storyboard And then of course linked it to an IBOutlet of type MTMathUILabel in my code file. It works successfully in the case of iOS but fails in macOS Even When I use MTMathUIView Custom Class in the Identity Inspector of Storyboard.
In accordance to their macOS example File I typed similar code in my ViewController.Swift as given below:
var mathViewCode: MTMathUILabel = MTMathUILabel()
#IBOutlet weak var mathViewIB: MTMathUILabel!
override func viewDidLoad() {
super.viewDidLoad()
mathViewIB.latex = "\\lim_{x\\to\\infty}\\left(1 + \\frac{k}{x}\\right)^x = e^k"
mathViewCode.latex = "\\int_{-\\infty}^{\\infty} \\! e^{-x^2} dx = \\sqrt{\\pi}"
self.view.addSubview(mathViewCode)
}
When from the above code I execute only the programmatically called MTMathUILabel Variable Code then simply a blank window opens without any output in it. But when I try to use the IBOutlet Variable to print latex in the Custom NSView (whose Custom Class in Attributes Inspector has been set to MTMathUIView not MTMathUILabel because then it crashes) the app again opens with a blank window but this time with the following warning:
Failed to set (contentViewController) user defined inspected property
on (NSWindow): -[NSView setLatex:]: unrecognized selector sent to
instance 0x60000330d7c0
If in Storyboard's Identity Inspector for the Custom NSView I set the Custom Class to MTMathUIView then the Interface Builder Does not Crash but it doesn't work either and if I set it to MTMathUILabel then the Interface Builder Crashes with the following error:
IB Designables: Failed to render instance of MTMathUILabel: The agent
threw an exception.
However, in the above scenario (where the Storyboard's Custom NSView's Custom Class in Attributes Inspector has been set to MTMathUILabel) the app compiles successfully but throws the following run time error after crashing:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
As you can see, I have tried to follow the approaches given in their official macOS Sample Project but nothing works in my case even though their Sample Project successfully compiles and runs well in my Xcode.
Please help me with this iosMath Library because I really want to use it because of its Beautiful Output and great features or please suggest some other Math Library to type in LaTeX in my Mac Apps that really runs on macOS with Swift.
Huge Thanks In Advance!!
I ran into the same problem.
I don't have a solution, but it is possible to use iosMath with MacOs and
swift.
I created my Project LatexPic and added it to the original podfile. Now you can use it in macOS App in view controller like:
let latexlabel = MTMathUILabel()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
self.view.addSubview(latexlabel)
latexlabel.backgroundColor = .white
latexlabel.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
latexlabel.latex = "\\frac{2}{3}"
}
Podfile:
workspace 'iosMath.xcworkspace'
install! 'cocoapods', :deterministic_uuids => false
target 'iosMathExample' do
project 'iosMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'iosMathTests' do
project 'iosMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'MacOSMath' do
project 'MacOSMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'LatexPic' do
use_frameworks!
project 'LatexPic.xcodeproj'
pod 'iosMath', :path => './'
end
I am a novice learning Swift and xcode by rewriting a code I originally developed in Javascript/PHP/MySql. I am working in macOS, using a storyboard in xcode as my basis for development. At the moment I am developing a SplitView. In the Master side I have an OutlineView. It has three levels, the outer two are expandable, and, until today, it worked just fine. All levels were populated, visible, and expandable where appropriate. I had Swift(4.0) and xcode (9.1) up-to-date as far as I know. So, today I decided it was time to update from Sierra to High Sierra. My master view has now gone completely blank. Nada. I tried to track the problem down and discovered, using the debugger in xcode, that the outlineView function in the NSOutlineViewDelegate extension to my MasterViewController is, apparently, not being called at all! I checked the Connections Inspector, and the connections to DataSource and Delegate are still intact. I searched online and found a few people with what seemed to be vaguely related recent problems associated with Cocoa bindings, but I could not connect their problem solution to mine since I am not using Cocoa bindings...it's on my list, but I am not there yet. The only thing I know that changed was going from Sierra to High Sierra. Any suggestions? Thanks!
ADDED: I now know a bit more about the problem.
Here is the code that works prior to High Sierra:
class ViewController: NSViewController {
#IBOutlet weak var webView: WebView!
#IBOutlet weak var outlineView: NSOutlineView!
var feeds = Feed
let dateFormatter = DateFormatter()
override func viewDidLoad() {
super.viewDidLoad()
dateFormatter.dateStyle = .short
if let filePath = Bundle.main.path(forResource: "Feeds", ofType: "plist") {
feeds = Feed.feedList(filePath)
print(feeds)
}
}
The code is taken from a tutorial on the OutlineView on the Ray_Wenderlich.com site. I patterned my code after this and both the tutorial and my code worked...until High Sierra. Apparently, until High Sierra, the system would spontaneously parse "feeds" and generate the outlineView display. With High Sierra the behavior changed and it no longer spontaneously produced the outlineView, neither in the tutorial nor my project. The result was a blank outLineView.
In a comment added to the tutorial, I now find that someone else had encountered the same behavior and suggested that the code now needed:
outlineView.reloadData(),
but my naive implementation of that suggestion simply generated a runtime error,
"[NSView reloadData]: unrecognized selector sent to instance"
Just make sure that when you start a new ‘Playground’ you have macOS as an application checked and not IOS. If you have IOS checked Swift will import UIKit (instead of Cocoa) which will cause your problem. GL.
Using the example found here:
https://github.com/CosmicMind/Samples/tree/master/Projects/Programmatic/PageTabBarController
How can I reproduce this without making any of the viewcontrollers as the root viewcontroller?
Material 2.8.0 replaces this component with the TabsController and you can try a sample TabsController project. As well, the TabsController is a UIViewController, so you can treat it as such. Hope this helps.
I have an application written in osx swift, and I need help with a particular behavior/issue. I have the application set to be above all other windows using this code:
self.window!.level = Int(CGWindowLevelForKey(Int32(kCGScreenSaverWindowLevelKey)))
A little issue with it, from what I've seen, is that it does work... but if I go to my launchpad applications menu, the window still shows up. That's exactly how I want the window to behave, but whenever I hit a button within the window, the application resets to the normal desktop to function properly. I have a link below demonstrating this:
https://gyazo.com/f4d05c10ad7b5dbf8b95f3bd2aa23cc4
See how I'm getting taken out of my launchpad and then reset to the normal desktop screen whenever I hit buttons within my application? I just really need to fix this issue.
Is there any info.plist property that I can use to prevent this from happening? Is there any piece of code I could use to make my window use-able everywhere without resetting it to the proper desktop environment? Thanks in advance!
NSFloatingWindowLevel might be a better choice:
import Cocoa
let kCGFloatingWindowLevel: CGWindowLevel =
CGWindowLevelForKey(CGWindowLevelKey.FloatingWindowLevelKey)
#NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
#IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification) {
self.window!.level = Int(kCGFloatingWindowLevel)
}
}
The window level type you are currently using is primarily meant for screensaver windows. If you want a floating palette or window then using the above should give you the desired behavior.
↳ NSWindow : NSFloatingWindowLevel
I know there is a similar question but the OP seems to think his problem was only on the simulator and so not such an issue... But I think mine is in both.
I was having a problem adapting an app for iCloud storage (when trying to observe for NSUbiquityIdentityDidChangeNotification). I could not see what the problem was with my code and so...
...after hours of banging my head against a wall I have set up a new project in Xcode (v6.1 6A1046a) to try and narrow it down. It seems it must be a very basic problem indeed...
The only things I have done in this new projects are:
Enable iCloud capabilities for 'Key-value storage' and for 'iCloud
Documents'(using the default container) - no error messages, appears to be set up fine.
Add a label and a button to the provided view controller in IB.
Add an IBOutlet for both and hook up an IBAction to change the label text when pressed.
For clarity, the only code I added to an empty 'Single View Application' template is:
#IBOutlet weak var label: UILabel!
#IBOutlet weak var button: UIButton!
#IBAction func buttonPressed(sender: AnyObject) {
self.label.text = "You pressed the button"
}
So if I run the project from Xcode in the simulator or on the device, or if I run the project directly on the device, it launches fine and the button works properly - as you would expect...
The problem is:
If I am running on the device from Xcode & I go to the Settings->iCloud->iCloud Drive on the device and toggle the switch for my app (from/to either state) the app crashes. I'm getting no feedback except this:
If I am running the app directly on the device and try and toggle iCloud Drive setting, when I go back into the app it appears to restart (the view is being reset, along with the label.text - neither of which happen if I just visit settings without touching the switch).
It also has the habit of freezing my device completely, which is mildly irritating.
I'm new to iCloud development so I guess I may be missing something really basic...
As I say it's an empty project with only a couple of lines of additional code so it's probably not something I HAVE done. Which limits it to something I HAVEN'T done. I am trying to follow as many tutorials as I can find and as much apple documentation as well. I just can't see any obvious steps I may have overlooked.
Unless it's the expected behaviour, or an Apple issue I guess.
Thanks for any help - it's driving me nuts!
iOs kill your app when you change iCloudDrive state. This is standard iOs behavior you can check this with build in applications(Safari for example).