【问题标题】:Activity indicator should be displayed when navigating from UITableView1 to UITableView2从 UITableView1 导航到 UITableView2 时应显示活动指示器
【发布时间】:2010-01-28 10:06:37
【问题描述】:

我想在从一个 UITableView1 导航到另一个 UITableView2 时显示一个活动指示器,并在表格完全加载时停止。

我正在使用 XML 解析来获取 UITableView2 的单元格内容。

【问题讨论】:

    标签: iphone objective-c uitableview activity-indicator


    【解决方案1】:

    以下代码可能会对您有所帮助...

    在 UITableView2 的 .h 文件中:

    声明变量

    UIActivityIndicatorView *progressInd;
    

    创建属性

    @property (nonatomic, retain) UIActivityIndicatorView *progressInd;
    

    并声明方法

    - (UIActivityIndicatorView *)progressInd;
    

    在 UITableView2 的 .m 文件中:

    @synthesize progressInd;
    

    定义这个方法(调整x,y,width,width位置)

    - (UIActivityIndicatorView *)progressInd {
    if (progressInd == nil)
    {
        CGRect frame = CGRectMake(self.view.frame.size.width/2-15, self.view.frame.size.height/2-15, 30, 30);
        progressInd = [[UIActivityIndicatorView alloc] initWithFrame:frame];
        [progressInd startAnimating];
        progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
        [progressInd sizeToFit];
        progressInd.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
                                        UIViewAutoresizingFlexibleRightMargin |
                                        UIViewAutoresizingFlexibleTopMargin |
                                        UIViewAutoresizingFlexibleBottomMargin);
    
        progressInd.tag = 1;    // tag this view for later so we can remove it from recycled table cells
    }
    return progressInd;
    }
    

    在你的解析开始的- (void)viewDidLoad方法中

    [self.view addSubview:self.progressInd];
    

    在解析结束处使用以下行

    [self.progressInd removeFromSuperview];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      相关资源
      最近更新 更多