Note that there are some explanatory texts on larger screens.

plurals
  1. POUINavigationBar troubles
    primarykey
    data
    text
    <p>In my app, i'm using a custom UINavigationBar and custom UIBarButtonItems in a NavigationController. My (custom) NavigationBar looks fine, but when I want to place my own backBarButtonItem and RightBarButtonItem, it goes wrong. </p> <p>Installing my own backBarButtonItem doesn't work at all (after a PushViewController method). I use this code: </p> <pre><code> UIButton *home = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *homeImage = [UIImage imageNamed:@"Topbarback"]; [home setBackgroundImage:homeImage forState:UIControlStateNormal]; home.frame = CGRectMake(0, 0, 51, 30); UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:home]; [self.navigationItem setBackBarButtonItem:backButton]; </code></pre> <p>I also have my own rightBarButtonItem. I am able to get it on my NavigationBar, but it isn't calling the method I want to do it. Here's my code for that one:</p> <pre><code> UIButton *home = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *homeImage = [UIImage imageNamed:@"Topbarback"]; [home setBackgroundImage:homeImage forState:UIControlStateNormal]; home.frame = CGRectMake(0, 0, 51, 30); UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithCustomView:home]; // self.navigationItem.backBarButtonItem = cancelButton; [self.navigationItem setBackBarButtonItem:cancelButton]; </code></pre> <p>After a couple of hours looking on the internet for a solution with no result, I hope that you guys can help me!</p> <p>Thanks!</p> <p>EDIT: Sorry posted the wrong code for the last issue: </p> <pre><code>UIButton *home2 = [UIButton buttonWithType:UIButtonTypeCustom]; [home2 setTitle:@"Sort" forState:UIControlStateNormal]; [home2.titleLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]]; UIImage *homeImage2 = [UIImage imageNamed:@"Topbarbutton"]; [home2 setBackgroundImage:homeImage2 forState:UIControlStateNormal]; home2.frame = CGRectMake(0, 0, 77, 30); UIBarButtonItem *cancelButton2 = [[UIBarButtonItem alloc] initWithCustomView:home2]; [cancelButton2 setTarget:self]; [cancelButton2 setAction:@selector(sorteren)]; self.navigationItem.rightBarButtonItem = cancelButton2; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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