Three20 网络连接时如何对视图进行模态化
在网络连接期间,有没有办法设置查看页面模式?我的意思是,如果网络正在连接,页面中的所有控制器都不会响应用户操作Three20 网络连接时如何对视图进行模态化,three20,presentmodalviewcontroller,Three20,Presentmodalviewcontroller,在网络连接期间,有没有办法设置查看页面模式?我的意思是,如果网络正在连接,页面中的所有控制器都不会响应用户操作 我更新了如下代码: - (void)loadView { [super loadView]; _hudView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)]; _hudView.backgroundColor = [UIColor colorWithRed:0 green:0 bl
我更新了如下代码:
- (void)loadView
{
[super loadView];
_hudView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)];
_hudView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
_hudView.clipsToBounds = YES;
_hudView.layer.cornerRadius = 10.0;
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_activityIndicatorView.frame = CGRectMake(65, 40, _activityIndicatorView.bounds.size.width, _activityIndicatorView.bounds.size.height);
[_hudView addSubview:_activityIndicatorView];
[_activityIndicatorView startAnimating];
_captionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)];
_captionLabel.backgroundColor = [UIColor clearColor];
_captionLabel.textColor = [UIColor whiteColor];
_captionLabel.adjustsFontSizeToFitWidth = YES;
_captionLabel.textAlignment = UITextAlignmentCenter;
_captionLabel.text = @"Loading...";
[_hudView addSubview:_captionLabel];
NSArray *buttonNames = [NSArray arrayWithObjects:@"hehe",@"xixi",nil];
UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithItems:buttonNames];
segmentControl.frame = CGRectMake(0, 0, TTApplicationFrame().size.width/2, TT_ROW_HEIGHT-10);
segmentControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentControl.momentary = NO;
segmentControl.tintColor = [UIColor darkGrayColor];
segmentControl.selectedSegmentIndex = 0;
[segmentControl addTarget:self action:@selector(switchPage:) forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = segmentControl;
TT_RELEASE_SAFELY(segmentControl);
self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
self.tableView = [[[UITableView alloc] initWithFrame:TTApplicationFrame() style:UITableViewStylePlain] autorelease];
self.tableView.rowHeight = 80.f;
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:self.tableView];
[self reload];
[self updateView];
}
然后像这样展示:
- (void)showLoading:(BOOL)show {
if (show) {
self.loadingView = _hudView;
}
else {
self.loadingView = nil;
}
}
正如我在评论中所说,它仍然无法覆盖UISegmentedControl的按钮,用户仍然可以单击这些按钮…创建一个HUD(您将在TTCatalog应用程序中看到的一个带有UIActivityIndicators的漂亮视图)这将阻止视图,并在您发出请求时通知用户发生了什么。 只需通过
[self.view addSubview:theHUDview]插入它们即可代码>
不过,这不一定是个好设计,相反,在后台异步进行网络调用。谢谢,伙计,这真的很有帮助!但我的情况是:数据通过响应按钮单击操作开始加载,按钮位于navigator UISegmentedControl上,因此UIActivityIndicators无法覆盖这些按钮,它们仍然可以在网络连接期间单击…好的,我理解。没有什么能阻止你显示一个模态的VIEW控制器,它完全由半透明/透明的视图组成,中间有一个HUD。