ActivityIndicator(菊花)的用法


1,在视图文件中拖拽一个 Activity Indicator View并且声明

#import <UIKit/UIKit.h>

@interface XViewController : UIViewController

@property (weak, nonatomic) IBOutlet UILabel *myLabel;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *myActivityIndicatorView;
@end

 

2,运用 startAnimating 和stopAnimating方法控制菊花是否转动

//
//  XViewController.m
//  ssss
//
//

#import "XViewController.h"

@interface XViewController ()

@end

@implementation XViewController
@synthesize myLabel;
@synthesize myActivityIndicatorView;

-(void)myMethodName
{
    //加载此方法以后Label名为 welcome
    myLabel.text = @"welcome";
    //停止动画
    [myActivityIndicatorView stopAnimating];
    //将菊花隐藏掉
    myActivityIndicatorView.hidden = YES;
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    [myActivityIndicatorView startAnimating];//加载的时候动画开始运行
    //2秒后运行名为myMethodName的方法
    [self performSelector:@selector(myMethodName) withObject:nil afterDelay:2.0f];
  //selector(方法名)

} - (void)viewDidUnload { [self setMyLabel:nil]; [self setMyActivityIndicatorView:nil]; [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } @end


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM