Note that there are some explanatory texts on larger screens.

plurals
  1. POApp crash on click of tab button second time
    primarykey
    data
    text
    <p>In my app i have tab bar and in it there is three tab button. but on one of it when i pressed it second time it crash the app. Other button are working fine.</p> <p>This is the .m file code</p> <pre><code>-(void)viewWillAppear:(BOOL)animated { scrollView.contentSize = CGSizeMake(320, 500); [super viewWillAppear:YES]; } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.title = NSLocalizedString(@"Contact Us", @"Contact Us"); self.tabBarItem.image = [UIImage imageNamed:@"contactTab.png"]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. [self.navigationController.navigationBar setTintColor:[UIColor blackColor]]; scrollView.contentSize = CGSizeMake(320, 500); scrollView.scrollEnabled = YES; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.view endEditing:YES]; } -(BOOL) textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } - (BOOL)textViewShouldBeginEditing:(UITextView *)textView { [textView becomeFirstResponder]; return YES; } - (void)keyboardWasShown:(NSNotification *)notification { // Step 1: Get the size of the keyboard. CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; // Step 2: Adjust the bottom content inset of your scroll view by the keyboard height. UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, keyboardSize.height, 0.0); scrollView.contentInset = contentInsets; scrollView.scrollIndicatorInsets = contentInsets; // Step 3: Scroll the target text field into view. CGRect aRect = self.view.frame; aRect.size.height -= keyboardSize.height; if (!CGRectContainsPoint(aRect, self.activeTextField.frame.origin) ) { CGPoint scrollPoint = CGPointMake(0.0, self.activeTextField.frame.origin.y - (keyboardSize.height-15)); [scrollView setContentOffset:scrollPoint animated:YES]; } } - (void) keyboardWillHide:(NSNotification *)notification { UIEdgeInsets contentInsets = UIEdgeInsetsZero; scrollView.contentInset = contentInsets; scrollView.scrollIndicatorInsets = contentInsets; } // Set activeTextField to the current active textfield - (void)textFieldDidBeginEditing:(UITextField *)textField { self.activeTextField = textField; } // Set activeTextField to nil - (void)textFieldDidEndEditing:(UITextField *)textField { self.activeTextField = nil; } // Dismiss the keyboard - (IBAction)dismissKeyboard:(id)sender { [self.activeTextField resignFirstResponder]; } </code></pre> <p>So which code is crashing my app?</p> <p>Edited :</p> <p>AppDelegate.m</p> <pre><code> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; tabBarController = [[UITabBarController alloc] init]; //Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController HomeViewController * homeViewController = [[HomeViewController alloc] init]; UINavigationController *homeNav = [[UINavigationController alloc] initWithRootViewController:homeViewController]; ContactUsFormViewController *contactUsFormViewController = [[ContactUsFormViewController alloc] init]; UINavigationController *contactNav = [[UINavigationController alloc] initWithRootViewController:contactUsFormViewController]; BookingFormViewController *bookingFormViewController = [[BookingFormViewController alloc] init]; UINavigationController *bookingNav = [[UINavigationController alloc] initWithRootViewController:bookingFormViewController]; NSArray* controllers = [NSArray arrayWithObjects:homeNav,contactNav,bookingNav, nil]; tabBarController.viewControllers = controllers; [self.window setRootViewController:tabBarController]; sleep(2); [self.window makeKeyAndVisible]; return YES; } </code></pre> <p><img src="https://i.stack.imgur.com/MgYQU.png" alt="log of crash"></p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload