uiactivityindicatorview在UIPopOverview控制器iphone中不工作
我让uipopovercontroller具有uitableview,我想在uitableview方法的didselectrowatindexpath方法中开始设置uiactivityindicatorview的动画。这是我的密码uiactivityindicatorview在UIPopOverview控制器iphone中不工作,iphone,ios,ipad,uipopovercontroller,uiactivityindicatorview,Iphone,Ios,Ipad,Uipopovercontroller,Uiactivityindicatorview,我让uipopovercontroller具有uitableview,我想在uitableview方法的didselectrowatindexpath方法中开始设置uiactivityindicatorview的动画。这是我的密码 -(IBAction)btnA_Clicked:(id)sender{ self.objuiviewCon = [[myuiviewController alloc] initWithNibName:@"myuiviewController" bundle:
-(IBAction)btnA_Clicked:(id)sender{
self.objuiviewCon = [[myuiviewController alloc] initWithNibName:@"myuiviewController" bundle:nil];
[self.objuiviewCon setDelegate:self];
self.ObjApopCon = [[UIPopoverController alloc] initWithContentViewController:self.objuiviewCon];
[self.ObjApopCon setPopoverContentSize:CGSizeMake(self.objuiviewCon.view.frame.size.width, self.objuiviewCon.view.frame.size.height)];
[self.ObjApopCon presentPopoverFromBarButtonItem:btnA permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
@interface myuiviewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{
IBOutlet UITableView *tblList;
IBOutlet UIActivityIndicatorView *actiIndi;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [myarr count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSLog(@"cell called");
cell.textLabel.text = [myarr objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"didSelectRowAtIndexPath called");
[actiIndi startAnimating];
}
-(iAction)b单击:(id)发件人{
self.objuiviewCon=[[myuiviewController alloc]initWithNibName:@“myuiviewController”bundle:nil];
[self.objuiviewCon setDelegate:self];
self.ObjApopCon=[[UIPopoverController alloc]initWithContentViewController:self.objuiviewCon];
[self.ObjApopCon setPopoverContentSize:CGSizeMake(self.objuiviewCon.view.frame.size.width,self.objuiviewCon.view.frame.size.height)];
[self.ObjApopCon presentPooverfrom BarbuttonItem:btnA PermittedArrow方向:UIPopOverArrow方向任何动画:是];
}
@接口myuiviewController:UIViewController{
ibuitableview*tblList;
IBUIActivityIndicator视图*ActivityIndi;
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节{
返回[myarr计数];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil){
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier]自动释放];
}
NSLog(@“被调用的单元”);
cell.textlab.text=[myarr objectAtIndex:indexath.row];
返回单元;
}
-(void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath
{
NSLog(@“didSelectRowAtIndexPath called”);
[启动活动];
}
还设置了在interface builder和委托中连接的所有iOutle。但我的问题是我的didSelectRowAtIndexPath方法正在调用,但activityindicator没有设置动画
我在使用协议单击表视图行时调用webservice,所以我需要uiactivityindicatorview设置动画,直到获得webservice的输出
如有任何建议,将不胜感激 检查活动视图,表可能是UIActivityIndicator在UITableView后面。 还要检查它是否被隐藏
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"didSelectRowAtIndexPath called");
[tableview bringSubviewToFront:actiIndi];
[actiIndi startAnimating];
}
对于您所说的,DidSelectRowatineXpath中还有一些代码:。也就是说,您正在从那里调用的方法调用webservice 我认为所有的问题都是你在同步调用webservice。您必须记住,用户界面中的每一个更改只有在方法完成后才能生效。因此,如果不将控制返回到主接口循环,startAnimating将不起任何作用 解决方案是,当您调用调用webservice的方法时,而不是:
[actiIndi startAnimating];
[self callWebservice:fooObject];
写下:
[actiIndi startAnimating];
[self performSelector:@selector(callWebservice:) withObject:fooObject afterDelay:0.0];
然后您将控制权返回到主循环,活动指示器将开始旋转,然后尽快调用另一个方法。感谢您的回答。它将把tableview带到前面。所以Activindi不会显示。谢谢你回答Gabriel。事实上,我已经把web服务调用放在了注释中,并试图设置指示器的动画,但它仍然没有设置动画。我已经把所有代码放在了注释中。我的代码只包含以下内容。NSLog(@“didSelectRowAtIndexPath called”);[启动活动];您在哪里调用任何web服务?我找不到它。我现在不给任何网络服务打电话。我的初始目标是在单击表视图行时开始设置指示器视图的动画。