In iOS 9, I see a new window appearing in my app that I didn't see before. An image is below. From walking the view tree, I suspect it may be coming from the UIRemoteKeyboardWindow -- but I don't know that. What is it, and what do I have to do to keep it from appearing?
EDIT: As a commenter pointed out, this is tied to the inputView, i.e. the keyboard. I don't want a keyboard and so disabled it by calling
self.inputView = [[UIView alloc]initWithFrame: CGRectZero];
That did kill the keyboard, but there is still the accessory. I've tried similar tricks to kill the accessory; none of them have worked, yet. Calling self.inputAccessoryView is returning nil, which doesn't help.
This got rid of it:
-(void) killAccessory {
UIView* input = self.inputView;
UIView* parent = input.superview;
parent.hidden = YES;
}
-(BOOL) becomeFirstResponder {
BOOL r = [super becomeFirstResponder];
[self killAccessory];
return r;
}
You can use the following code :
textField.inputAssistantItem.leadingBarButtonGroups = [[NSArray alloc] init];
textField.inputAssistantItem.trailingBarButtonGroups = [[NSArray alloc] init];
the textField use above is the textField which you tap to edit.
Related
I'm trying to figure out what is wrong with my app. It crashes EXC_BAD_ACCESS in release mode, but when I try checking for zombies, it doesn't crash via instruments. Without fail, I turn off zombie detection and it crashes.
When it does crash the only thing I can tell is that the very latest call in the vm allocation shows this viewDidLoad. So I'm wondering if there's something wrong here?
- (void)viewDidLoad
{
[super viewDidLoad];
//load abstract
if ( self.abstractId > 0 ){
[self startQuery:#selector(getAbstractWithId:)];
}
//setup nav bar
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"" style:UIBarButtonItemStylePlain target:nil action:nil];
[self.view addSubview:[self makeFavoriteButton]];
//add link attributes
self.linkAttributes = #{NSForegroundColorAttributeName: [UIColor colorWithHexString:emaGreen],
NSUnderlineColorAttributeName: [UIColor lightGrayColor],
NSUnderlineStyleAttributeName: #(NSUnderlinePatternSolid)};
//create text view
UITextView *tv = [[UITextView alloc] initWithFrame:self.view.frame];
tv.editable = NO;
tv.textAlignment = NSTextAlignmentLeft;
tv.text = #" ";
tv.backgroundColor = [UIColor whiteColor];
tv.scrollEnabled = YES;
tv.dataDetectorTypes = UIDataDetectorTypeLink;
tv.linkTextAttributes = self.linkAttributes; // customizes the appearance of links
tv.delegate = self;
// set the scroll indicators between nav and tabs
tv.scrollIndicatorInsets = UIEdgeInsetsMake(0,
0,
CGRectGetHeight(self.tabBarController.tabBar.frame),
0);
//add to property and view
self.tv = tv;
[self.view addSubview:tv];
//Create spinner view
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
self.hud = hud;
}
What other debugging options do I have here?
Thanks!
I'm going to guess it's this line:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"" style:UIBarButtonItemStylePlain target:nil action:nil];
To quote the documentation for the parameters of UIControl:
target: The target object—that is, the object to which the action message is sent. If this is nil, the responder chain is searched for an object willing to respond to the action message
action: A selector identifying an action message. It cannot be NULL
Strangely, this is not specified for UIBarButtonItem's initializer, but I see no reason why it shouldn't be true there as well, unless that class actually checks these parameters for null and behaves accordingly.
Perhaps your bar button item is trying to access the null selector to send it and is crashing there, or is trying to send it to some object that has already been released. This might only be brought on by some optimization -- for example, perhaps in release mode the button grabs a pointer to the function that would be called by a message send, instead of sending the message, as an optimization.
At the very least, passing nil there seems like mistake.
Thanks for the comments. Strangely, I finally got a console output in zombies, with the following KVO error message received but not handled.
Which I was able to track down to an observer that was not removed when dealloc'd. Worst bug ever. ugh. Thanks for the help!
-(void)dealloc
{
[self.queryQueue removeObserver:self forKeyPath:#"operations"];
}
I am using AGSPopupsContainerViewController to display multiple popups when touching on mapView we fetch more than one AGSGraphics.
Here is my code:
NSMutableArray *popups =[[NSMutableArray alloc]init];
AGSPopupInfo *popupinfo;
for (AGSGraphic *g in Graphics ) {
popupinfo =[AGSPopupInfo popupInfoForGraphic:g] ;
AGSPopup* popup = [AGSPopup popupWithGraphic:g popupInfo:popupinfo];
popup.allowEditGeometry = false;
[popups addObject:popup];
}
if (!popupVC) {
self.popupVC = [[AGSPopupsContainerViewController alloc] initWithPopups:popups
usingNavigationControllerStack:false];
}else{
[self.popupVC showAdditionalPopups:popups];
}
self.popupVC.delegate = self;
self.popupVC.doneButton = self.customActionButton;
self.popupVC.style = AGSPopupsContainerStyleCustomColor;
self.popupVC.barItemTintColor = [UIColor redColor];
self.popupVC.pagingStyle = AGSPopupsContainerPagingStyleToolbar;
// Animate by flipping horizontally
self.popupVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
// If iPad, use a modal presentation style
if([[AGSDevice currentDevice] isIPad])
self.popupVC.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:self.popupVC animated:YES completion:nil];
All works fine, I have the right number of pupups, the problem is that using the arrows in the toolbar I can only see the first and the last ones. Why? I am missing something?
Arrows are doing what they are supposed to do - using them will show you the first and the last popup. Swipe to the left (or right) and you'll see the rest of the popups.
In my app on button click i have add pickerview to the windows below is the code show that
- (IBAction)btnMake:(id)sender
{
pickerViewMake = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerViewMake.showsSelectionIndicator = YES;
pickerViewMake.dataSource = self;
pickerViewMake.delegate = self;
[pickerViewMake setBackgroundColor:[UIColor clearColor]];
[viewPicker addSubview:pickerViewMake];
[self.view.window addSubview:pickerViewMake];
}
-(void)removeAllPicker
{
[pickerViewMake removeFromSuperview];
[pickerViewModel removeFromSuperview];
[pickerViewYear removeFromSuperview];
[pickerViewTrim removeFromSuperview];
}
remove all picker is the method used for removing the picker from superview
it works
The problem is that on multiple clicking btnMake number of the picker view cones up then
removeallPicker method call than also pickerview does not remove from superview.
Do one Thing create one BOOL variable and set in viewdidload yes and check in function if it is yes then picker come and also make it no in btnmake method.
Try in the following way
if (<instance>)
{
[<instance> removeFromSuperview],<instance> = nil;
}
After this create your picker then it won't create multiple times, it will create only once.
I want to check if my view has already been added to the view, so that the user cannot repeatedly add the new UIViewController onto the view.
if (!self.fmovc)
{
self.fmovc = [[FMOVC alloc] initWithNibName: #"FMOVC" bundle:nil];
}
BOOL viewAlreadyDisplayed = NO;
for (UIView * b in self.view.subviews)
{
if ([b isKindOfClass:[FMOVC class]])
{
viewAlreadyDisplayed = YES;
}
}
if (!viewAlreadyDisplayed)
{
[self.view addSubview:self.fmovc.view];
}
This is not working because it never triggers
viewAlreadyDisplayed = YES;
What is the correct way to go about finding if your view is already being displayed?
Thanks,
-Code
Before adding just removeItFromSuperView...It may solve your prob
[self.fmovc.view removeFromSuperview];
[self.view addSubview:self.fmovc.view];
Make the UIView member variable say thatView;
if(!thatView) {
thatView = [[UIView alloc] init];
[self.view addSubView:thatView];
}
Once you release the superview, release thatView & make thatView to nil.
OR
always check & remove thatView if present from superview before allocating thatView.
Hope this Helps !!!
UICalloutView willRemoveSubview:]: message sent to deallocated instance;
This only happens when I tap the callout button, but not on the first and not on the 2nd tap, but from the 3rd tap. So I tap the custom AnnotationView, callout pops, thats good. I tap it again, callout pops, all good. I tap another one, boom crash with that message. It only happes if is set the right accesoryview to be a button.
One key aspect to keep in mind..only happens in iOS 6... (go figure).
I am really stuck on this one – some help would be appreciated.
if ([annotation isKindOfClass:[RE_Annotation class]])
{
RE_Annotation *myAnnotation = (RE_Annotation *)annotation;
static NSString *annotationIdentifier = #"annotationIdentifier";
RE_AnnotationView *newAnnotationView = (RE_AnnotationView *)[mapViews dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if(newAnnotationView)
{
newAnnotationView.annotation = myAnnotation;
}
else
{
newAnnotationView = [[RE_AnnotationView alloc] initWithAnnotation:myAnnotation reuseIdentifier:annotationIdentifier];
}
return newAnnotationView;
}
return nil;
Also, this is my initwithannotation method:
- (id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
if(self)
{
RE_Annotation *myAnnotation = annotation;
self = [super initWithAnnotation:myAnnotation reuseIdentifier:reuseIdentifier];
self.frame = CGRectMake(0, 0, kWidth, kHeight);
self.backgroundColor = [UIColor clearColor];
annotationView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"map_pin_pink.png"]];
annotationView.frame = CGRectMake(0, 0, kWidth - 2 *kBorder, kHeight - 2 * kBorder);
[self addSubview:annotationView];
[annotationView setContentMode:UIViewContentModeScaleAspectFill];
self.canShowCallout = YES;
self.rightCalloutAccessoryView = [[UIButton buttonWithType:UIButtonTypeInfoLight] retain]; ///if i take it out it doesnt crash the app. if i leave it it says that message
}
return self ;
}
In the initWithAnnotation method, there is this line:
self.rightCalloutAccessoryView =
[[UIButton buttonWithType:UIButtonTypeInfoLight] retain];
///if i take it out it doesnt crash the app. if i leave it it says that message
By "it", you must be referring to the retain and this implies the app is not using ARC.
Based on that, you should make the following corrections:
In viewForAnnotation, you need to autorelease the view when you alloc+init it otherwise there's a leak:
newAnnotationView = [[[RE_AnnotationView alloc]
initWithAnnotation:myAnnotation
reuseIdentifier:annotationIdentifier] autorelease];
In initWithAnnotation, remove the retain when creating the callout button since buttonWithType returns an auto-released object (and you don't want to over-retain it):
self.rightCalloutAccessoryView =
[UIButton buttonWithType:UIButtonTypeInfoLight];
Another possibly unrelated issue is that in initWithAnnotation, the code is calling super initWithAnnotation twice. This seems unnecessary and may be harmful. Remove the second call.
The above changes at least fix the issues with the code shown. However, there may be other, similar memory-management related issues in the rest of the app that may still cause crashes. Check and solve all issues reported by Analyzer.
Regarding the fact that "it only happens in iOS 6": iOS 6 may be less forgiving of memory-management errors or an internal change in the SDK may be exposing or manifesting these errors earlier. Regardless, the above fixes are necessary.
An unrelated point is there should be no need to manually create a UIImageView and addSubview it to the annotation view. You can just set the annotation view's image property.