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