我在按钮栏项的标识符列表中寻找 UIButtonTypeInfoLight 选项,但我没有看到它。那么,两个问题。
它只是丢失了,我必须在代码中手动创建它吗?我想知道他们为什么会忽略它。
假设我必须手动创建按钮以从中调用转场,我是否需要手动执行转场而不是使用 Storyboard?
我假设我会通过我的按钮调用的方法执行此操作 [self performSegueWithIdentifier:@"ShowChecklist"sender:nil];
。
创建我的按钮的代码是
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];
那么,这是一个常见的模式吗?我在做一些奇怪和不标准的事情吗?在我看来,如果我的 BarButton 只是一个显示“信息”的自定义按钮,我可以创建它并将其全部连接到 Storyboard 中,这在我看来很奇怪……但是对于这个,我必须全部用代码完成。
最佳答案
UIButtonTypeInfoLight 是一个 UIButton。按钮栏项目是 UIBarButtonItems。他们彼此无关。你只是混淆了苹果和橘子。
但是,一个 UIBarButtonItem 可以包含一个 UIButton。 (这仅仅是因为它可以包含任何 UIView。)所以将一个 UIButton 拖到工具栏中。您得到的是一个 UIBarButtonItem 包含一个 UIButton。如果您双击 UIBarButtonItem,您将获得 UIButton。现在您可以设置按钮的类型。
关于ios5 - UIButtonTypeInfoLight 在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9155054/