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.
Related
been googling this one for a good bit and i'm totally at a loss.
i'm porting to ios7 an app i built with a mapview with basic system annotations. everything is working great, the annotations are handling taps and acting as they're supposed to - but for some reason, there's no disclosure button appearing in the annotation. i haven't changed anything for prior ios7 releases and all the searching i've done has given me very little.
i've looked through changelogs and googled everything i can possibly come up with to solve this problem, and nothing has even remotely helped.
for my annotation view (which presented the old typical blue arrow button previously) i simply have …
UIButton* rightButton = [UIButton buttonWithType: UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = rightButton;
which looks right and should be right (again, it's fine in ios6 and before) be for some reason, any sort of representation of a button is just not appearing.
thanks for any help here.
hahah oh jeez, this is why i shouldn't be working so late.
the default color of the disclosure button is apparently white. like the default annotation background color.
derp.
I had the same problem and hopefully this can help someone else looking here, I didn't seem to require this for the disclosure indicator to appear before iOS7, but I forgot to set the mapView delegate. Once I added this to the viewDidLoad, my indicators started to appear (even though the annotations were appearing without it):
mapView.delegate = self;
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.
I want to have the virtual keyboard appear in my view on load and I want it to say visible for the lifetime of the view. There is a text field and I treat as the primary control for this view.
Initially, I called [self.textField becomeFirstResponder] in -viewWillAppear: following advice I've gotten here. Then, I came up with a different idea: I overloaded UIViewController's -becomeFirstResponder.
- (BOOL)becomeFirstResponder
{
if (self.primeResponder)
return [self.primeResponder becomeFirstResponder];
return [super becomeFirstResponder];
}
I'm not seeing any hidden problems with this, but then again, no one recommends it either. Am I missing something? Is this a bad approach? Please help.
In reviewing my old question, I thought now would be a good time provide an answer to this.
It works and does not have any major drawbacks.
I've had good luck with this method except in a peculiar circumstance. I used this to set a text field in a table view cell as the prime responder. In iOS 6, it didn't load the keyboard or highlight the textfield when the view was pushed onto the navigation controller stack.
See In iOS 6, -[UITextField becomeFirstResponder] doesn't work in -viewWillAppear: for my solution to that problem.
I've got an NSPopover that is shown from interaction with an NSStatusItem. I've blogged about the hacks I needed to do to make input even possible in this situation here: http://blog.brokenrobotllc.com/using-nspopover-with-nsstatusitem
I have an NSTextField inside the NSPopover's content view. When I open the NSPopover, the NSTextField appears as if it is key (the cursor blinks). But, when typing, nothing shows up. If I click the mouse in the field, my input starts showing up there.
I've tried things like invoking NSWindow's makeFirstResponder upon popoverDidShow:. There was no change in behavior from this. Anyone have any ideas here?
My guess is you need to make your app active; try calling
[NSApp activateIgnoringOtherApps:YES];
when you show your popover.
Edit: Of course, I could be wrong. This is all just off the top of my head.
I have a UIButton linked up in IB correctly(I believe). The button fires inconsistently, every time I reload the view to show updated info, the button works sometimes and sometimes does not.It gives no errors. I can't find a pattern to when it works and when it doesn't, the same code is run every time I open the view and it still works when it wants. Besides linking it in IB I have also tried to addTarget in ViewDidLoad and remove the IB connection but it still has the same inconsistency,
[_buttonScreen addTarget:self action:#selector(buttonScreenClicked) forControlEvents:UIControlEventTouchUpInside];
If I add NSLog(#"Clicked"); to buttonScreenClicked I see that the method doesn't always get called, what would cause it to do this, I have made sure that I set:
[_buttonScreen setAlpha:0.1];
[_buttonScreen setHidden:NO];
[_buttonScreen setUserInteractionEnabled:YES];
I have no Image, text, or color in the button, but it still works sometimes.
I'm using AFKPageFlipper on the same view but it still had the same problem before I added AFKPageFlipper, so I don't think its that.
If anyone could point me in any direction to start trouble shooting this problem I would appreciate.
Thanks
I just had the same problem and worked it out. The 5 seconds is the clue.
Somewhere you have a gesture recognizer covering the same space as your button. More specifically you have a gesture recognizer that is eating your Taps but not your LongPresses. If you just tap the button the gesture recognizer runs off with your event; Hold your finger down long enough and the gesture recognizer no longer considers it a tap and the event is passed through to your button.
Instrument your Tap gesture recognizer handlers and the problem should pop out at you.
Make sure you don't have any other UIView descendants overlaying the button (like a transparent UIScrollView) as these will intercept the touch events first.
Also make sure that the containing view (the view with the button in) is correctly sized, by default you can place a view outside the bounds of another view and the clipsToBounds is set to false so you will see it but not be able to interact with it.
Things to try:
Do you have any other actions on the button?
Do you have any other UIViews which could possibly be accepting the key presses (above or below, or un-shown)
Also, please check that you have only one UIViewController instance for this screen. Other issues may arrise because of that.
What happens if you dont set the alpha level?
Do you release the object properly in the dealloc only ?
Hope this helps