這讓我瘋狂。我有一個webview和一個UIActivityIndicator。UIActivityIndicator無法在中心加載
由於某些原因,它不會加載到web視圖的中心,而是加載到左側。
嘗試了幾個教程來得到這個工作,但無法弄清楚。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"PASSED URL IS %@", passedURL);
NSString *fullURL = passedURL;
//NSString *fullURL = @"http://107.22.183.71/index.php";
NSURL *url = [NSURL URLWithString:fullURL];
activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
//Put the indicator on the center of the webview
[activityIndicator setCenter:self.view.center];
//Assign it to the property
self.activityIndicator=activityIndicator;
//Add the indicator to the webView to make it visible
[self.webView addSubview:self.activityIndicator];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_webView loadRequest:requestObj];
}
我懷疑它的加載webview或指標的順序。
該指標本身工作正常,我已經實現了所有需要的代表。
任何幫助非常感謝。
這是兩者的組合。您的回答是將其推向中心的最後一步 – EHarpham