1
我在故事板中以编程方式显示图像,并成功处理横向/纵向(请参阅下面的代码)。我正在尝试通过Interface Builder直接在故事板中的相同视图上添加自定义按钮。该按钮只是在应用程序运行时不显示。只有图像。你能告诉我在故事板视图上做到这一点的方式吗?或者我应该以编程方式添加它?或者在界面构建器中重做所有100%的东西?真的不知道如何混合和匹配这2种方法...iOS:自定义按钮不在故事板上显示
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[[self navigationController] setNavigationBarHidden:YES animated:YES];
UIImage *startImage = [UIImage imageNamed:@"title.png"];
UIImageView *startImageView = [[UIImageView alloc] initWithImage:startImage];
self.startImageView = startImageView;
[self.view addSubview:startImageView];
}
- (void) orientStartImageView
{
UIInterfaceOrientation curOrientation = [UIApplication sharedApplication].statusBarOrientation;
if (curOrientation == UIInterfaceOrientationPortrait || curOrientation == UIInterfaceOrientationPortraitUpsideDown) {
[self.startImageView setFrame:CGRectMake(-128, 0, 1024, 1024)];
}else{
[self.startImageView setFrame:CGRectMake(0, -128, 1024, 1024)];
}
}
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self orientStartImageView];
}
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
[self orientStartImageView];
}
谢谢。我真的想知道应用程序如何处理图像排序。 – Armand 2013-02-19 13:21:25
您可以使用此方法管理它 – Dilip 2013-02-19 13:42:53
[self.view insertSubview:<#(UIView *)#> aboveSubview:<#(UIView *)#>]; [self.view insertSubview:<#(UIView *)#> atIndex:<#(NSInteger)#>]; [self.view insertSubview:<#(UIView *)#> belowSubview:<#(UIView *)#>]; – Dilip 2013-02-19 13:44:13