0
UIBarbutton項目は(..クリックに応答しませんUIBarButtonItem not clickable on iOS 11 beta 7?)iOS11/Xcodeの9 UIBarButtonItem問題
問題は、ポストで説明されているように制約を加えたものですが、まだ動作しません。誰かが自分のコードを見て、私が間違っていることを教えてもらえますか?
UIImage* image = [UIImage imageNamed:@"test.png"];
CGRect frame = CGRectMake(0, 0, 30, 30);
UIButton* someButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[someButton setImage:image forState:UIControlStateNormal];
[someButton setFrame:frame];
[someButton setShowsTouchWhenHighlighted:YES];
[someButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
NSLayoutConstraint * widthConstraint = [someButton.widthAnchor constraintEqualToConstant:30];
NSLayoutConstraint * HeightConstraint =[someButton.heightAnchor constraintEqualToConstant:30];
[widthConstraint setActive:YES];
[HeightConstraint setActive:YES];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:someButton];
self.toolbar.items = [NSArray arrayWithObjects:item, nil];