Going from event editor back to calendar creates blacked out area near bottom - calendarkit

I've encountered this problem both in my own CalendarKit app as well as the sample app found here. The issue is that when I click on an event and enter the EKEventViewController and then navigate back, the calendar now looks like this:. Looking at the view hierarchy, it looks like the TimelineView has been truncated at the bottom a little. Any idea on what's going on/how to fix? Thanks.
I tried using present instead of pushing navigation controller, but then the "Delete Event" button on the bottom of the EKEventViewController just doesn't show up.

It's a bug in EventKitUI framework projecting itself onto the other ViewControllers. To fix it, add this line to CalendarViewController:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setToolbarHidden(true, animated: false)
}
This will solve your issue.

Related

viewWillTransitionToSize called even if i press power button

While my app is running and i press power button (To lock the device) this function is calling.
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
And returning current state UIApplicationStateActive using
[UIApplication sharedApplication].applicationState
How to prevent calling this function ? or how to ignore if power button is press? because i don't want to perform any action on powerButton press.
Precondition : Launch Screen should be present.
This function calling on app minimise and power button press due to new feature of multitasking.
You can make your application full screen to solve this problem.
Check on ✓ Requires full screen
But this is not the proper solution because you have to adopt multitasking in some case.
I investigated this behaviour. It seems this happen only on iPads and maybe it related to split view function.
Try to ignore the code running inside the method by adding at the beginning of the method:
if([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
return;
}
UPDATE:
I found the cause of this issue.
When you press "power" button, the application window changes their size and sometimes it happens before the application sets the correct applicationState:
That's why this method calls.
Sorry for my english =)

Button does not react

I have a strange behaviour with an NSButton. It works normal until I do so voodoo somewhere else in my app. Right then the button does no longer react on click events. It still looks normal (so not disabled). It just does not do anything when I click it. Any idea where I should look in the properties of NSButton that might have been changed accidentally? (Quite sure I did not touch the button itself.)
Ensure your button is in a 'touchable' zone in its superView. I mean It have ro be placed inside it superView bounds (If not, you can see It, depending on Clipping properties, and you can't interact with It). In order to check it, set a color to your container view.
Also check userInteraction is enabled...
Hope It helps.
If your button is just not giving the animation, it might be an Xcode bug. I had a similar problem before, and I filed a bug, and it got fixed on the next Xcode version. Check out my SO question. Toolbar bar button item not working properly in SplitViewController
If you really need to give it an animation, you could probably do it in code with something like this. Please note that this is untested so it may not work, or you might need some fixing, but you get the idea :)
- (IBAction)buttonAction:(id)sender {
self.button.titleLabel.textColor = [UIColor lightGrayColor];
// Action
self.button.titleLabel.textColor = [UIColor darkTextColor];
// Or with delay
[self performSelector:#selector(changeButtonColor) withObject:nil afterDelay:0.1];
}
I figured it out. The button opened a transient popover. In order to close this popover due to an action I had coded
view.window!.orderOut(self)
After replacing it by
view.window!.performClose(self)
the strange effect was gone. I'm not sure, but this looks like a bug in the Swift runtime. I'll report it and see what comes out.

Custom Annotation View do not work on iOS6

I'm using the J4n0 Callout code (github) to implement a custom annotation in MapKit.
It was working just fine on iOS5. But on iOS6 I have 2 problems:
Annotations are displayed over the AnnotationView (see picture 1).
The first Click on an Annotation opens the AnnotationView just fine, but the second click opens an annotation with a bad size (see picture 2).
Does anyone using this library have some similar problem/solution?
I can give some code if needed!
If annotations are displayed over the AnnotationView try to code:
- (void)didMoveToSuperview {
[super didMoveToSuperview];
[self.superview bringSubviewToFront:self];
}
Just in case above solution doesn't work try
view.layer.zposition = 1
I am not sure whether you used the same code as mine, I downloaded it from somewhere to custom the annotationView and I also figured out that in the second time, the size is incorrect. I had noticed that the removeAnnotation function, will also make the annotationView call its didMoveToSuperview once again! Then I dug into the codes in didMoveToSuperview and found that the codes that I downloaded (i hope u meet the same one), do some animation in it so this will make the animation codes call twice. That makes the problem that "second click open an annotation with a bad size"
So remove this animation codes, or make it call somewhere else and NOT in didMoveToSuperview but properly. I hope this will help you, and hope you will share your advice if find out that I am wrong.

Problem avoiding first responder on a NSTextField

I need to change behavior of input fields in a really simple app:
Whenever i launch the application the first text field get the focus, but i don't want this behavior.
I tried checking "Refuses first responder" in IB. It works but with this option checked i can't move between input fields pressing "tab" button.
What can i do to avoid focus at startup and keep the ability to move with tab keyboard button ?
The (previously) accepted answer isn't reliable and doesn't work very well. The other answer with the hidden NSTextField isn't very great either because now you have a new element in your Tab order.
The solution I've found works best so far is:
Make the NSTextField refusesFirstResponder YES on app launch.
Then, in viewDidAppear for the controller, go ahead and set refusesFirstResponder back to NO.
Everything behaves perfect after launch, and I don't have a greedy NSTextField stealing first responder on app startup.
I found the solution, you can add [window makeFirstResponder:nil]; after awakeFromNib for example in applicationDidfinishLaunching.
window?.makeFirstResponder(nil) does not work for me - when I check who is the first responder, it is the window (and not a NSTextField) but still, the first NSTextField is selected and active. The solution for me (though I know not the cleanest one) was to create a hidden text field and make it the first responder every time the window did load.
window?.makeFirstResponder(nil) worked only when I set all NSTextFields to RefuseFirstResponder, but then using Tab to switch between them of course do not work.
This worked for me,
override func viewDidAppear() {
Timer.scheduledTimer(withTimeInterval: 0.1, repeats: false) { [weak self] (timer) in
NSApplication.shared.windows[0].makeFirstResponder(self?.textUsername)
let tRange = self?.textUsername.currentEditor()?.selectedRange
self?.textUsername.currentEditor()?.selectedRange = NSMakeRange((tRange?.length)!, 0)
}
}

Keyboard appears on top of view where no user interaction should be allowed

I have a window-based project with two UITextFields to take input from the user.
Both are in my view controller.
I have to parse stuff in the background, so I need something that blocks user interaction in the meanwhile.
I came across this Cocoa With Love tutorial to create a loading view on top of everything. It actually works pretty well, for the most part; it works when ever the text field resigns first responder.
There is one circumstance where it doesnt work, though. When I type something in the first text field and then select the second one, the loading screen will appear, but the keyboard is on top of it, so the user could type something. I want the loading screen to be on top of the keyboard.
In the tutorial, it says to call the keyboard's superview. What is the keyboard's superview?
I tried the following different snippets in my view controller, but nothing works.
loadingView = [LoadingView loadingViewInView:[self.view.window.subviews objectAtIndex:0]];
loadingView = [LoadingView loadingViewInView:self.view];
loadingView = [LoadingView loadingViewInView:self.view.superview];
How can I make the loading screen appear on top of everything ?
The simple solution is to dismiss the keyboard when you show the loading view. I don't think you're allowed to put anything on top of the keyboard.
That said, you could try using the root window as the view to see if that has any effect.