UITableView inside childviewcontroller not receiving all taps - ios

I've got a UITableview that displays the search results of a UISearchController. They are inside of a Childviewcontroller.
I write the text on the textfield of the parentviewcontroller and it passes the text to the searchbar of the child view controller.
This all works fine.
But for some reason, when I am choosing a result in the child view controller's tableview, it is not very responsive.
After typing in the search text in the textfield (having the textfield as the firstResponder), most of the times I have to tap more than once to select a row.
(P.S. userInteraction is enabled, otherwise no touch would ever go through.)
Any idea why?

I have same problem, and my solution is:
- (void) displayContentController: (UIViewController*) content{
[content.view setFrame:recorderView.bounds];
UINavigationController *childNavController = [[UINavigationController alloc] initWithRootViewController:content];
childNavController.toolbarHidden = NO; // if you show toolbar
childNavController.view.frame = content.view.frame;
[self addChildViewController:childNavController];
[recorderView addSubview:childNavController.view];
[childNavController didMoveToParentViewController:self];
}
content is my subViewController

Is this for Swift or for Objective-C? Also are you placing a UI Tap Gesture Recognizer on the views that you wish to be touchable?

Related

InputAccessoryView covers the bottom bar

Any idea how to get an inputAccessoryView to anchor to the tab bar rather than the bottom of the screen?
I have created a UIViewController and overridden the following methods:
-(BOOL)canBecomeFirstResponder {
return YES;
}
-(UIView *)inputAccessoryView {
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, 44);
self.keyboardInputAccessoryView =[[BRKeyboardInputBarView alloc] initWithFrame:frame leftButtonTitle:#"Left" andRightButtonTitle:#"Send"];
[self.keyboardInputAccessoryView setDelegate:self];
[self.keyboardInputAccessoryView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.keyboardInputAccessoryView removeFromSuperview];
return self.keyboardInputAccessoryView;
}
View controller with inputAccessoryView covering the tab bar
By the looks of it the view controller adds the view to the window rather than the current view controllers view, which would explain its positioning. However if I remove the line:
[self.keyboardInputAccessoryView removeFromSuperview];
I get a crash when I tap in the textview of my accessory view:
The view hierarchy is not prepared for the constraint:<NSLayoutConstraint:0x7fa0c2ca5f80 BRKeyboardInputBarView:0x7fa0c2d6fad0.bottom == UIInputSetContainerView:0x7fa0c295a2c0.bottom>
So I guess what I am asking is what is the correct way to add a keyboard accessory view so that it plays nicely with auto layout and avoids the crash, but also anchors itself to the view and not the window?
What you are seeing is the right behaviour.
The results you are seeing is because of the fact that UIViewController is a UIResponder subclass. By overriding the inputAccessoryView and returning an instance of a view, UIViewController will take care of placing that view at the bottom of the screen and animating it appropriately when keyboard appears or disappears.
If you want to add this bar on top of your keyboard, then you need to set the property inputAccessoryView of a textField/textView to your custom view.

Bring UIView over the current UIVIewController on a NavigationApplication

I develop a project which is based on navigation structure.
It is intended that in the current ViewController to display a generic view.This view contains information about the menu of the application.
I must show this uiview when user tap a button from the navigation bar.
I can't display this view over the current viewcontroller.
Can anyone help me?
I have a customNAvigation "
#interface CustomNavigation : UIView
- (IBAction)goToProfileInRootVC:(id)sender;
- (IBAction)goToRootinRootVC:(id)sender;
- (IBAction)goToPreviewVC:(id)sender;
- (IBAction)goToMenu:(id)sender;
+ (CustomNavigation*)showInView:(UIView*)parentView;
#end
When user tap on the Menu button from the navigtion I must display an UIView which must contain a list with the categories from menu.
This view must be displayed over the current UIViewcontroller.
I just give you basic suggestion,
Add You view (custom) in self.view (as Hidden), such like
self.mycustomView.hidden = YES; // default is hidden;
[self.view addSubView:self.mycustomView];
on Button click method, make this mycustomView is as visible
-(void)btnClick:(UIButton *)sender
{
self.mycustomView.hidden = NO;
}

iOS: WEPopoverController in MKMapView

Because i have more than one element to display at a given location in a mapview, i'd like to display a WEPopoverController in the MKMapView when a given MKPinAnnotationView has been selected.
Presenting the content, which is a tableview works fine so far. I've subclassed the MKPinAnnotationView and when the annotation view gets clicked, i call my custom presentation method.
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
[view openCustomPopoverInFrame:self.view.frame];
[mapView deselectAnnotation:view.annotation animated:NO];
if (_lastAnnotationView != view) {
[_lastAnnotationView closeCustomPopover];
_lastAnnotationView = view;
}
}
- (void) openCustomPopoverInFrame:(CGRect) frame {
CGRect fromFrame = self.frame; //Pin Annotation View Frame
WEPopoverContentViewController *contentViewController = [[WEPopoverContentViewController alloc] initWithStyle:UITableViewStylePlain];
contentViewController.delegate = self;
WEPopoverController *viewController = [[WEPopoverController alloc] initWithContentViewController:contentViewController];
//[viewController setPassthroughViews:[NSArray arrayWithObjects:contentViewController.view, contentViewController.tableView, nil]];
viewController.delegate = self;
//set the displayed content
....
_myPopoverController = [viewController retain];
[viewController presentPopoverFromRect:fromFrame inView:self.superview permittedArrowDirections:UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown animated:YES];
[contentViewController release];
[viewController release];
}
Also selecting buttons in the tableview cells work find and i get the expected response (the method gets called and the popovercontroller stays on top of the view hierarchy).
My problem is, when i click on the WEPopoverController Content (one of the table view cell, in the center, where no button is located), the tap event gets passed through to the map view and therefore hides the popover controller. What can i do, to prevent passed through tap events?
I tried several solutions e.g. set the passThroughViews and also manipulating the hitTest:withEvent: method in the WETouchableView and always return nil, but that also doesn't help me any further.
Best
Nic
EDIT
I've now debugged the hitTest:withEvent: method in the WETouchableView a little more in dept and it seems, that it always returns an instance of UITableViewCellContentView, which i think should be correct so far.
EDIT
So to be a little bit more clear, i want to display a popover controller and when it gets tapped it should neighter disappear like it is the usual annotation behavior nor the underlying view should get called. It should stay on top of the view and the tap event should get caught by the table view and call the specific method (tableView:didSelectRowAtIndexpath:).
I've looked at this solution aswell, but it seems not to work for me and the underlying view (wich is the map view) gets called.
Ok, what worked for me, was to add a UIButton with a transparent background color as the first subview of the table view cell. All Tap Events on the cell now get caught by the UIButton. Btw all swipe events get caught by the table view, so at least that works fine.
To be honest, this isn't a really nice solution, but it works for me. I'd really appreciate any further suggestions!
Best
Nic

Accessibility: How to always set the focus on the navigation item's title view

I'm using a UINavigationController in my app.
When using VoiceOver the backButton has the focus, when a new ViewController is pushed.
I'd rather have the accessibilityLabel of the titleView been focused if the view appears,
so that its accessibilityLabel is read first.
Using UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.navigationItem);the titleView seems to be focused, when I create and push the view controller for the first time.
But when I come back from another view controller (pushed onto the first one), the focus is on the back button again.
I should've set the the accessibilityLabel of the titleView, not the navigationItem.
The following works:
- (void) viewDidLoad
{
...
self.navigationItem.titleView.accessibilityLabel = #"[text-to-speak]";
}
- (void) viewDidAppear
{
[super viewDidAppear];
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.navigationItem.titleView);
}

Push view controller after setting view

Suppose i have a uiview in 1 screen and i want to view the same view in fullscreen mode on click of a button.
On click of a button the following function is called.
-(IBAction)fullScreen
{
FullScreenViewController *mv = [[FullScreenViewController alloc] init];
mv.fullview = minimizedView;
//minimizedView is a UIView already created with a specified frame
// fullview is a UIView decalred in FullScreenViewController
[[self navigationController] pushViewController:mv animated:YES];
}
In the FullScreenViewController.m the viewDidLoad function is as follows :
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addSubview:fullview];
}
On click of the fullscreen button, the view appears but on click of back button, the minimized view in the previous page dissapears.
Is it wrong to do this?
You dont need to use two views to implement this. In your code, your are navigating from one view to another view. You dont need to do that. Your minimizeView itself having a property "setFrame:" to increase and decrease its frame to resize of that subview in your current view itself. Learn how to resize the UIView.

Resources