문제

I'm looking for the UIButtonTypeInfoLight choice in the identifier list for button bar items, and I'm not seeing it. So, two questions.

  1. Is it just missing and I'll have to create it manually, in code? I'm wondering why they would omit it.

  2. Assuming I do have to create the button manually, to call a segue from it,do I need to manually perform the segue rather than using the storyboard?

I'm assuming I'd do this [self performSegueWithIdentifier:@"ShowChecklist" sender:nil]; from the method that my button is calling.

The code that created my button is

UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(infoButtonAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *modalButton = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
[self.navigationItem setRightBarButtonItem:modalButton animated:YES];

So, Is this a common pattern? Am I doing something weird and nonstandard? It just seems to me to be weird that if my BarButton were just a custom button that said "info" I could create it and wire it up all in the Storyboard... but for this one, I have to doit all in code.

Th menu:

도움이 되었습니까?

해결책

UIButtonTypeInfoLight is a UIButton. Button bar items are UIBarButtonItems. They have nothing to do with each other. You're just confusing apples and oranges.

However, a UIBarButtonItem can contain a UIButton. (That's merely by virtue of the fact that it can contain any UIView.) So drag a UIButton into a toolbar. What you get is a UIBarButtonItem containing a UIButton. If you double-click the UIBarButtonItem, you get the UIButton. Now you can set the button's type.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top