Ios 无法在布局视图xcode情节提要集上创建按钮
我曾尝试在屏幕上创建带有自定义图像中心的按钮,但无效。因此,我求助于以编程方式为主self.view创建按钮。在执行时,不能添加按钮 下面是我的代码。请查看Ios 无法在布局视图xcode情节提要集上创建按钮,ios,objective-c,xcode,uibutton,storyboard,Ios,Objective C,Xcode,Uibutton,Storyboard,我曾尝试在屏幕上创建带有自定义图像中心的按钮,但无效。因此,我求助于以编程方式为主self.view创建按钮。在执行时,不能添加按钮 下面是我的代码。请查看 UIButton *buttonA = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 88, 30)]; [buttonA setImage:[UIImage imageNamed:@"rc_logo.png"] forState:UIControlStateNormal];
UIButton *buttonA = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 88, 30)];
[buttonA setImage:[UIImage imageNamed:@"rc_logo.png"] forState:UIControlStateNormal];
UIBarButtonItem *buttonItemB = [[UIBarButtonItem alloc] initWithCustomView:buttonA];
navigationItem.rightBarButtonItem = buttonItemB;
[navigationBar pushNavigationItem:navigationItem animated:NO];
UIImage * ssssImage = [UIImage imageNamed:@"menu_back.png"] ;
UIButton * btnPair ;
[self setPosition : btnPair image: ssssImage positionAt: CGRectMake(self.view.frame.size.width/2 - ssssImage.size.width/2,
self.view.frame.size.height * 0.18 ,
ssssImage.size.width/2, ssssImage.size.height/2)];
[self.scrollContain addSubview:btnPair];
}
-(void) setPosition : (UIButton * ) btn image : (UIImage * ) deviceImage positionAt : (CGRect) frame {
btn = [[UIButton alloc] initWithFrame: frame];
[btn setImage:deviceImage forState:UIControlStateNormal ];
[btn setFrame: frame];
btn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
btn.titleLabel.textAlignment = NSTextAlignmentLeft;
}
试着给它背景色的调试过程和检查,通过放置断点和观察帧和隐藏属性的按钮,你们正在创建
请指定哪个按钮不添加UIBarButton或UIButton?UIButtons,而不是UIBarBUttons