xcode tab bar keeps showing up - ios

I am trying to hide the tab bar in my UIView this is how my controller looks
[PFUser logInWithUsernameInBackground:username password:password block:^(PFUser *user, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Sorry" message:[error.userInfo objectForKey:#"error"] delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alertView show];
}
else {
[self.navigationController popToRootViewControllerAnimated:YES];
}
i keep inserting this code befroe self navigation controller but it doesnt work
controller.hides.BottomBarWhenPushed=YES;
I'm unsure whats wrong im sorry im a noob to this

To make a view be hidden, set its hidden to YES.
If this is a UINavigationController's tab bar, then you can tell the navigation controller directly to hide the tab bar (https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html#//apple_ref/occ/instm/UINavigationController/setToolbarHidden:animated:)

Related

TouchID : How to get touch id authentication attempts?

I need to implement touch ID and have to show alert to user for authentication attempts left. Below code Im using.
reply block not getting called after one wrong authentication attempt. Its getting called after 3 continues wrong authentication attempt. Is there any way to get count of wrong authentication attempts..?
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = #"Touch ID Test to show Touch ID working in a custom app";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:#"Success" sender:nil];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:error.description
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil, nil];
[alertView show];
NSLog(#"Switch to fall back authentication - ie, display a keypad or password entry box");
});
}
}];
} else {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Error"
message:authError.description
delegate:self
cancelButtonTitle:#"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
}
I went through the documentation, it is not possible to show alert in each failed attempt. Just refer the documentation
LocalAuthentication in iOS. You can show alerts at different error cases. After 3rd failed attempt LAError.authenticationFailed will be called and after 5th failed attempt LAError.touchIDLockout will be called. You can display the alerts here. For more info refer Apple LAError documentation.

iOS UIAlertView being shown more than once

Hi I have used the following function to call an alert view with a specific message. The NSLogs are being printed only once but alert view is called more than once.
I am using UITabBarController for any additional info.
- (void)showUIAlertWithMessage:(NSString *)message {
NSLog(#"showUIAlertWithMessage called");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Something went wrong!😕😕"
message:message
delegate:self
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}

Change iOS tab view from alert

I have a tabbed application with 2 tab views. I want to change the view from the second tab to the first when the user presses "OK" on an alert view.
The following code snippet works when I use it on an -IBAction button pressed, but it doesn't do anything when I use it inside the alert code:
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:0];
Why does it not work when used as below, in my SeondViewController.m in my
- (void)viewDidLoad {
[super viewDidLoad];?
UIAlertView *alert =[[UIAlertView alloc]
initWithTitle:#"Camera and Target coincident"
message:msg
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:0];
I'm just learning this, so anything you can offer would be helpful.
When I use the following code:
if ([ theProjection Trans_Initialise] == 1) {
NSString * msg = nil;
UIAlertView *alertView =[[UIAlertView alloc] initWithTitle:#"Camera and Target coincident" message:msg delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:#"OK"]) {
self.tabBarController.selectedIndex = 0;
}
}
I get the error message on -(void) alertView "Invalid argument type void to unary expression" Am I doing something grammatical, or is it (quite possibly) something I just didn't understand?
First of all, you need a delegate call back from the alert view informing you about the button that was clicked.
Your alert view should be created like this :
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:#"Camera and Target coincident" message:msg delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
Then in your m file implement the function :
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:#"OK"]) {
self.tabBarController.selectedIndex = 0;
}
}

Need to UIAlertView show on current page and page not change

When I submit with empty textbox page is change and UIAlertView show after that, but I want to UIAlertView show in current page and page can not change (Stay on Signin Viewcontroller).
Thanks
- (IBAction)btnSignin:(id)sender {
[PFUser logInWithUsernameInBackground:_txtSigninUsername.text password:_txtSigninPassword.text block:^(PFUser *user, NSError *error) {
if (!error) {
NSLog(#"Login user!");
_txtSigninUsername.text = nil;
_txtSigninPassword.text = nil;
[self performSegueWithIdentifier:#"Signin" sender:self];
}
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"ooops!" message:#"Sorry we had a problem logging you in" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
}];
}
My Storyboard :
You're performing the Segue with "Signin" identifier with the condition "error".
So when there's an error first your code performs the segue and then performs the error message.
Change "!error" with "user" and it should hopefully work. Let me know.

UIAlertView seems to freeze application when uploading data to Parse.com

Hello I am using parse to help with the backend of my iOS app and I created a button that will save my text in my textfields and upload it to the cloud when I click a button.
The code for the button and the alert that pops up is as follows
- (IBAction)savebutton:(id)sender {
// Create PFObject with recipe information
PFObject *recipe = [PFObject objectWithClassName:#"GolfTimes"];
[recipe setObject:_nameTextField.text forKey:#"Name"];
[recipe setObject:_prepTimeTextField.text forKey:#"MemberNumber"];
[recipe setObject:_NumberOfGolfers.text forKey:#"NumberOfGolfers"];
[recipe setObject:_RequestedTime.text forKey:#"RequestedTime"];
NSArray *ingredients = [_ingredientsTextField.text componentsSeparatedByString: #","];
[recipe setObject:ingredients forKey:#"Telephone"];
// Show progress
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = #"Sending...";
[hud show:YES];
// Upload recipe to Parse
[recipe saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
[hud hide:NO];
if (!error) {
// Show success message
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Request Sent" message:#"We will get back to you with confirmation." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
// Notify table view to reload the recipes from Parse cloud
[[NSNotificationCenter defaultCenter] postNotificationName:#"refreshTable" object:self];
// Dismiss the controller
[self dismissViewControllerAnimated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Upload Failure" message:[error localizedDescription] delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
}];}
Although the data does send properly and the view controller does close as I made it do, the Alert seems to freeze the app and I cannot click the "Ok" most of the time. When I do click the "OK" button the app simulator shuts down.
Any suggestions or help?
I believe you need to dispatch the UIAlertView to the main thread like so when you want to show them: EDIT: You can't have the delegate of the UIAlertView be on the UIViewController you just dismissed! That's why it's crashing; setting the delegate to: nil should fix that.
dispatch_async(dispatch_get_main_queue(),^
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Request Sent" message:#"We will get back to you with confirmation." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
[[NSNotificationCenter defaultCenter] postNotificationName:#"refreshTable" object:self];
[self dismissViewControllerAnimated:YES completion:nil];
});

Resources