XCTest. Detecting access gallery alert view - ios

I have a problem with detecting UIAlertView which appear when I wont to get photo from photo gallery in UI XCTest. My code:
let app = XCUIApplication()
let alertView = app.alerts["\u{201c}MyAppName\u{201d} Would Like to Access Your Photos"]
Alert view is already on screen but in alertView I got nil. Anybody knows how to resolve this problem?

Maybe some charters in alertView Value is miss.
use index instead String Value.
let alertView = app.alerts.elementBoundByIndex(0)
and example for tap alertButton
app.alerts.elementBoundByIndex(0).buttons["OK"].tap()
it works for me

Related

FBSDKAppInviteDialog doesn't load list of friends

UIWebView page that was opened by showing FBSDKAppInviteDialog doesn't load list of friends as usual, but stops either at an empty page state or at the infinite loading indicator state.
let text = "invite text"
content.appLinkURL = URL(string: "valid_url_to_fb_me")!
content.promotionText = text
content.promotionCode = "\(code)"
let dialog = FBSDKAppInviteDialog()
dialog.fromViewController = self.viewController
dialog.content = content
dialog.delegate = self
dialog.show()
And FBSDKAppInviteDialogDelegate methods were not called.
This behaviour was not reproducible a week ago.
iOS Simulator 10.2, same behaviour on the iOS 10.2.1 on real device the iPhone 5S and iPad mini 9.2.
Facebook SDK - 4.15.1
Thanks in advance for any help or sugestions.
the bug is on Facebook's side:
https://developers.facebook.com/bugs/721787828000962/
The Facebook bug mentioned by BoygeniusDexter (https://developers.facebook.com/bugs/721787828000962/) is actually on Android not iOS.
Are you using the deprecated UIActionSheet to open FBSDKAppInviteDialog? If so removing UIActionSheet is your solution: https://developers.facebook.com/bugs/172327909915305/

Wrong pin entry, snap a photo without presenting the camera on screen

I am trying to have my application take a photo of an "intruder" when the wrong pin is entered into my application.
I have set up the UIImagePickerController(Below) and can make the application display the camera and take photos with no problem what so ever.
picker = UIImagePickerController() //make a clean controller
picker.delegate = self
picker.allowsEditing = false
picker.sourceType = UIImagePickerControllerSourceType.Camera
picker.cameraCaptureMode = .Photo
presentViewController(picker,animated: true,completion: nil)
Then i proceed to attempt this as to make the new set up for the picker
picker.showsCameraControls = false
I know that has to be set to false to call picker.takePicture()
Now I dont want to present the picker viewController and be able to call takePicture() but this is not hitting the delegate method of didFinishPickingMediaWithInfo.
I have tried using a custom overlay as well, but to no avail of 100% hiding the camera.
How do I go about not showing or displaying the camera on screen and being able to grab this picture of the front camera?
I have permission for access as well.
The other question posted on here of a similar topic does not solve this issue for help in swift.
Is the only way possible using AVFoundation?
If so, any help would be appreciated

Simple Overlay View on UIImagePickerControler.Camera

I am initiating a camera capture via UIImagePickerController (sourceType = .Camera)
I have created a simple ViewController overlayVC and designed it in IB
I wish to overlay overlayVC on top of the camera now. How do I accomplish this in swift?
I understand I need to use UIImagePickerController.cameraOverlayView property but this property wont take overlayVC directly. What step am I missing?
I figured it out my self:
let overlay = self.storyboard?.instantiateViewControllerWithIdentifier("OverlayVC")
image.cameraOverlayView = overlay?.view

iOS AlertView App Extension

I'm working in a custom keyboard (iOS App Extension). I have a UICollectionView in my Keyboard Layout, so when one item is selected I want to show a message (UIAlerView for example).
Here is my code:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
...
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:#"My Title"
message:#"Enter User Credentials"
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
}
I get this error: 'Feature not available in extensions of type com.apple.keyboard-service'
So...is there any way to show a message from an App Extension?
EDIT:
Here is an example. The IKEA Emoticons Keyboard shows a message (like an Android Toast after selecting one item).
I also have tried this library:
iOS Toast Library
Sad to say that, but there's no way to show a UIAlertView in keyboard extension. Actually, nothing above the frame of InputViewController can be showed. It's pretty clear in the Apple's doc:
...a custom keyboard can draw only within the primary view of its UIInputViewController object... it is not possible to display key artwork above the top edge of a custom keyboard’s primary view, as the system keyboard does on iPhone when you tap and hold a key in the top row.
As for message inside the keyboard, there are some useful libraries that can help us with it. For example https://github.com/scalessec/Toast and https://github.com/sergeylenkov/PTHintController.
Finally I solved the problem. It's not the best solution, but at least I get the effect that I wanted.
I've created a View simulating a Toast in the xib file and set it to hidden.
When the item is selected, I show the "faked" Toast for 2 seconds and hide it again.
self.popUpView.hidden = NO;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 2.0 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
self.popUpView.hidden = YES;
});
I don't know if it's a good solution, but I really had to find a solution for that.
For Swift you can use this :
self.popUpView.isHidden = false
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
self.popUpView.isHidden = true
}

UIAlertView has scrollable title and message on iOS7

I have a UIAlertView with text in it that can be displayed on iOS6 without any problem.
However in iOS7 the title and message of this alert are in a scrollview.
I'm creating the alert with following code
self.newCategoryAlertView = [[[UIAlertView alloc] initWithTitle:NSLocalizedString(#"MessageTitleNewCategory", nil)
message:NSLocalizedString(#"MessageTextNewCategory", nil)
delegate:self
cancelButtonTitle:NSLocalizedString(#"ButtonCancel", nil)
otherButtonTitles:NSLocalizedString(#"ButtonOK", nil), nil] autorelease];
self.newCategoryAlertView.tag = alertViewTypeNewCategory;
self.newCategoryAlertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[self.newCategoryAlertView textFieldAtIndex:0].delegate = self;
[self.newCategoryAlertView textFieldAtIndex:0].autocapitalizationType = UITextAutocapitalizationTypeSentences;
[[self.newCategoryAlertView textFieldAtIndex:0] setReturnKeyType:UIReturnKeyDone];
[[self.newCategoryAlertView textFieldAtIndex:0] setKeyboardAppearance:UIKeyboardAppearanceDefault];
[self.newCategoryAlertView textFieldAtIndex:0].enablesReturnKeyAutomatically = YES;
[self.newCategoryAlertView show];
The result on iOS7 is this:
I tried to make the the text shorter with no success and the documentation of UIAlertView didn't give me a hint.
How do I workaround this behavior?
EDIT:
This is how it looks when scrolled down. As you can see the complete message is visible.
In my opinion that's a good behaviour, as there's no space in the screen to show the keyboard and also de UIAlert. I'm almost sure that if you make the app work in portrait orientation, the alert will show ok with no scrollable title and message.
If the app only runs in landscape orientation, and you don't want to have a scrollable view, I guess the best solution will be maybe to keep the UIAlert message, but taking away the UIAlert tilte.
I hope this helped!
I have used a custom control URBAlertView. I found a similar problem with this & I have reported that to the author on the github here.
There was a fix provided by the author under the commit here. However you can also refer the top three commits on the repo here.
I hope that may help you all to figure out a solution

Resources