Note that there are some explanatory texts on larger screens.

plurals
  1. POUIButton crashing app on touch
    primarykey
    data
    text
    <p>I have a navigationController which holds a view with some buttons, but when I press a button I get a EXC_BAD_ACCESS error. I can't think what I'm doing wrong as the target is set right. It crashes whether the the button is added programmatically or via IB. </p> <p>Button Code: </p> <pre><code>UIButton *reportsButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; reportsButton.frame = CGRectMake(20, 100, 100, 50); [reportsButton setTitle:@"Reports" forState:UIControlStateNormal]; [reportsButton addTarget:self action:@selector(reportsButtonTouched:) forControlEvents:UIControlEventTouchUpInside]; </code></pre> <p>Function button is trying to access:</p> <pre><code>- (void)reportsButtonTouched:(id)sender { NSLog(@"working"); } </code></pre> <p>Error: </p> <pre><code>int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); //EXC_BAD_ACCESS code=1 } </code></pre> <p>The function the button is trying to access exists.</p> <p>Maybe it's something about the way the NavigationController functions that I'm not aware of, but I've done this before without any problems. </p> <p>Thanks for any answers, I really do appreciate the help I've got from this site before. </p> <p>EDIT: This is my AppDelegates didFinishLaunching incase that helps in any way.</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. UIViewController *homevc = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:homevc]; [self.window addSubview:nav.view]; [self.window makeKeyAndVisible]; return YES; } </code></pre>
    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