iOS VoiceOver Override Magic Tap in CallKit - ios

I am using CallKit to make a call.
In the InCall ViewController I have MagicTap gesture overridden:
- (BOOL)accessibilityPerformMagicTap
{
// ...
return YES;
}
However when I use the MagicTap guesture, it ignores the overridden method. Instead it ends the call.
How can I change this behavior to my custom action?

Related

Dismiss CNContactPickerViewController on call button press

Let's say, we have simple application with one view controller and single bar button item which will open CNContactPieckerViewController. So, I enter into picker view, choose contact, enter into details view. If there is implementation for contactPicker:didSelectContactProperty: delegate method in my view controller, pressing a call button will call delegate method and CNContactPickerViewController will be dismissed and for making a call I need to handle everything manually in delegate method. But if there is no implementation for contactPicker:didSelectContactProperty: delegate method, call will be made (based on what kind of call did you choose - GSM, WhatsApp or something else) but CNContactPickerViewController won't be dismissed.
Question
is there any possibility dismiss CNContactPickerViewController without losing functionalities for handling calls.
you can add observer while call connected and disconnected for both states and can dismiss the CNContactPickerViewController controller. but i would suggest use contactPicker:didSelectContactProperty : delegate to achieve this functionality.
1.import CallKit framework
#import <CallKit/CXCallObserver.h>
#import <CallKit/CXCall.h>
2.Conform class to CXCallObserverDelegate protocols.
3.Make strong reference to CXCallObserver object like as
#property (nonatomic, strong) CXCallObserver *callObserver;
4.Initialize callObserver object while you are presenting CNContactPieckerViewController like as
CXCallObserver *callObserver = [[CXCallObserver alloc] init];
[callObserver setDelegate:self queue:nil];
_callObserver = callObserver;
5.Finally implement the delegate method
-(void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call {
if (call.hasConnected) {
NSLog(#"********** voice call connected **********/n");
} else if(call.hasEnded) {
[(your CNContactPieckerViewController object) dismissViewControllerAnimated:YES completion:nil];
NSLog(#"********** voice call disconnected **********/n");
}
}

Detecting multiple touches WKInterfaceTable

Is there a way to detect if a table row has already been selected, right now I am protecting against multiple pushes with a boolean like so:
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
pushed=NO;
}
- (void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {
// if pushed, just return else continue and set pushed to true
if (pushed) {
return;
}
pushed=YES;
[self pushControllerWithName:rowData[#"controllerIdentifier"] context:nil];
}
There is no built-in method to detect multiple touches in a WKInterfaceTable. The technique that you're using is the same technique that I use in my Watch app. In my case, I maintain a BOOL for each row indicating whether it's enabled or not. Based on that BOOL, I updated my cell to show a "disabled"-looking state, though of course, it isn't technically disabled.

Dynamically added UITableViewDelegate method does not respond to user interaction

I currently develop an iOS library which tracks user's interaction such as button tap, text editing and so on.
For tracking a table view's row selection, I use method swizzling to wrap tableView:didSelectRowAtIndexPath: delegate method.
When tableView:didSelectRowAtIndexPath: delegate method is defined in an application that use the library, it works well.
However, when tableView:didSelectRowAtIndexPath: delegate method is not defined, I add it dynamically to the delegate instance but tableView:didSelectRowAtIndexPath: delegate method is not called by a table view.
// Add an original tableView:didSelectRowAtIndexPath: if not exists.
if ( ! [delegate respondsToSelector:#selector(tableView:didSelectRowAtIndexPath:)] )
{
BOOL result = class_addMethod( [delegate class], #selector(tableView:didSelectRowAtIndexPath:), (IMP)tableViewDidSelectRowAtIndexPathIMP, types );
if ( ! result )
return;
}
When I call the added method manually, it responds.
Any ideas?

UIWebView canPerformAction do not disable some menu items

In a UIWebView, I want a certain class div element to display only one custom contextual menu entry. So that I implemented the canPerformAction:: method in the UIWebView delegate like this:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (self.webView.superview != nil) {
BOOL isMyClass=[[self.webView stringByEvaluatingJavaScriptFromString:#"window.getSelection().getRangeAt(0).startContainer.parentNode.className;"] isEqualToString:#"myClass"];
if (isMyClass) {
if (action == #selector(myAction:)) {
return YES;
} else {
return NO; // should disable any other menu items
}
}
}
return [super canPerformAction:action withSender:sender];
}
The result is quite strange: when the user selects such a myclass div, most menuItems are not displayed (cut: copy: past:...) but select: and selectAll: are still displayed (along with myAction). Under debugger, I notice that these two select/selectAll methods do not fire canPerformAction:: in the delegate... Where are these two method fired?
I think I know why you may be having problems.
I had the same question and similar frustration:
"Why are select: and selectAll: not appearing when stepping through calls to canPerformAction::?"
I then realized that the firstResponder when displaying the UIMenuController was just a container, and that this class had a member that was actually extending the UITextView class. Since the sharedMenuController interacts with the first responder in the Responder chain, implementing canPerformAction in the container skipped select and selectAll because they had already been handled by the textView member (the REAL firstResponder in this situation).
What you should do is find which object is your firstResponder when displaying the UIMenuController, find any responder objects it might own until you find the highest responder on the stack, and implement canPerformAction there.
Good Luck!
Sometimes, when application is used on the iPad device, with no connection to Xcode, the menu correctly displays only the authorized item... Sometimes not... Very erratic behaviour indeed

Return to root view in IOS

To some this may sound like a daft question. I've searched around, and found little, mostly because I cannot find the appropriate search terms.
Here what I want to do is:
The application begins at view A.
View A launches view B, and view B launches view C.
Is their a way for view C to return directly back to A without dismissing itself and thus exposing B. For example a main menu button.
You can call popToRootViewControllerAnimated: if you have a UINavigationController. If you specify NO to animate it, then it will just jump back to the root without showing B first.
I have discovered a solution to my problem. Its a bit dirty, (and I''ll probably get shot down in flames for it) but works very well under tests and is very quick to implement. Here's how I did it.
In my app I have a Singleton class called GlobalVars (I use this for storing various global settings). This class holds a boolean called home_pressed and associated accessors (via synthesise). You could also store this value in the application delegate if you wish.
In every view controller with a main menu button, I wire the button to the homePressed IBAction method as follows. First setting the global homePressed boolean to YES, then dismissing the view controller in the usual way, but with NO animation.
-(IBAction) homePressed: (id) sender
{
[GlobalVars _instance].homePressed = YES;
[self dismissModalViewControllerAnimated: NO];
}//end homePressed
In every view controller except the main menu I implement the viewDidAppear method (which gets called when a view re-appears) as follows.
-(void) viewDidAppear: (Bool) animated
{
if ([GlobalVars _instance].homePressed == YES)
{
[self dismissModalViewController: NO];
}
else
{
//put normal view did appear code here/
}
}//end viewDidAppead
In the mainMenu view controller which is the root of the app, I set the global homePressed boolean to NO in its view did appear method as follows
-(void) viewDidAppear: (Bool) animated
{
if ([GlobalVars _instance].homePressed == YES)
{
[GlobalVars _instance].homePressed == NO;
}
else
{
//put normal view did appear code here/
}
}//end viewDidAppear
There, this enables me to go back to the root main menu of my app from any view further down the chain.
I was hoping to avoid this method, but its better than re-implementing my app which is what I'd have to do if I wanted use the UINavigationController solution.
Simple, took me 10 minutes to code in my 9 view app. :)
One final question I do have, would my solution be OK with the HIG?

Resources