I have the following in my view did load on my table view controller:
UIButton *change_view = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[change_view setTitle:@"List" forState:UIControlStateNormal];
[change_view addTarget:self action:@selector(toggleView:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView: change_view];
self.navigationItem.rightBarButtonItem = button;
When I run the program, it doesn't show any title or the rounded rectangle button. However, if I change the type to UIButtonTypeInfoLight, it will show up... so what is the problem?
I'd prefer the way below to set the button's bounds.
[button setTitle:@"Title" forState:UIControlStateNormal];
[button sizeToFit];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With