I have a UITableViewController subclass. When I try to add a subView its not showing.
The subView is a UIImageView, I made a custom loading view (its shown when user is loading data from web).
But when I add,
[self.tableView addSubview:spinner];
[spinner startAnimating];
The spinner is not showing. What am I missing or I did wrong?
EDIT
Code of spinner
UIImageView *spinner = [[UIImageView alloc]init];
spinner.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"spin8.png"],
[UIImage imageNamed:@"spin7.png"],
[UIImage imageNamed:@"spin6.png"],
[UIImage imageNamed:@"spin5.png"],
[UIImage imageNamed:@"spin4.png"],
[UIImage imageNamed:@"spin3.png"],
[UIImage imageNamed:@"spin2.png"],
[UIImage imageNamed:@"spin1.png"],
nil];
Use MBProgress HUD Its an custom control through which you can easily add various type of Loading indicator
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeAnnularDeterminate;
hud.labelText = @"Loading";
[self doSomethingInBackgroundWithProgressCallback:^(float progress) {
hud.progress = progress;
} completionCallback:^{
[hud hide:YES];
}];
Use above code or there are lot of other options as well
尝试将其添加到tableView的contentView中:
[self.tableVew.contentView addSubview:spinner];
Try this
CGRect spinnerFrame = //frame of spinner
UIImageView *spinner = [[UIImageView alloc] initWithFrame:spinnerFrame];
spinner.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"spin8.png"],
[UIImage imageNamed:@"spin7.png"],
[UIImage imageNamed:@"spin6.png"],
[UIImage imageNamed:@"spin5.png"],
[UIImage imageNamed:@"spin4.png"],
[UIImage imageNamed:@"spin3.png"],
[UIImage imageNamed:@"spin2.png"],
[UIImage imageNamed:@"spin1.png"],
nil];
[self.tableView addSubview:spinner];
[spinner startAnimating];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.