簡體   English   中英

根據其父視圖旋轉SubView

[英]Rotation of SubView according to it's superview

我使用帶有自動布局支持的故事板創建了一個應用程序。 現在,我想在請求/響應上添加一個加載視圖。 我已經通過這樣的代碼創建了加載視圖

self=[super initWithFrame:f];
[self setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.7]];
CGPoint p=[self center];
self.activityIndicator=[[UIActivityIndicatorView alloc] initWithFrame: CGRectMake(p.x-37/2, p.y-32/2, 37, 37)];
[self.activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
[self addSubview:self.activityIndicator];

lblMsg=[[UILabel alloc] initWithFrame:CGRectMake(p.x-50/2,CGRectGetMaxY(self.activityIndicator.frame), 200, 30)];
lblMsg.text=@"Logging...";
lblMsg.backgroundColor=[UIColor clearColor];
lblMsg.textColor=[UIColor lightGrayColor];

[self addSubview:lblMsg];

self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
return self;

現在的問題是它沒有執行旋轉。 它總是以縱向模式進入。 我該如何對其應用自動旋轉功能。

也許這會幫助您嘗試

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

我找不到從哪里開始為UIActivityIndi​​catorView設置動畫。

[self.activityIndicator startAnimating];

用於loadView的最佳框架之一

1) https://github.com/jdg/MBProgressHUD

您可以使用NetworkActivityIndicator

發送請求時,請使用

[self setNetworkActivityIndicatorVisible:YES];

當回復回來時,使用

[self setNetworkActivityIndicatorVisible:NO];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM