【问题标题】:popover tableview shows then disappearspopover tableview 显示然后消失
【发布时间】:2013-07-15 14:43:08
【问题描述】:

单击按钮时,我将显示一个弹出视图,它是一个表格视图。

似乎一切正常,视图显示,但不到一秒钟就消失了。

tableview 包含一个字符串列表,我将 tablecell 设置为显示复选标记。

我注意到表格显示了在它显示的瞬间检查的所有项目

任何人都知道我错过了什么。

谢谢

哈桑

显示弹出框的代码

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"WholesalersList"]){
        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

        WholesalersViewController *vc = segue.destinationViewController;
        vc.wholesalers = [appDelegate.wholesalers mutableCopy];
        if ([segue isKindOfClass:[UIStoryboardPopoverSegue class]]){
            self.wholesalersPopoverController = [(UIStoryboardPopoverSegue *)segue popoverController];
            [self.wholesalersPopoverController setPopoverContentSize:CGSizeMake(334, 334)];
            //[self.wholesalersPopoverController setDelegate:self];
        }
    }
}

弹出表视图中的代码

#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section {
    if ([self.wholesalers count] == 0) {
        return 1;
    }
    else {
        return [self.wholesalers count];
    }
}

#pragma mark Table view delegate
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([self.wholesalers count] == 0) {
        return nil;
    }
    else {
        static NSString *CellIdentifier = @"WholesalerCell";

        UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];

        // Configure the cell.
        Wholesaler *ws = (Wholesaler *)[self.wholesalers objectAtIndex:indexPath.row];

        cell.textLabel.text = ws.name;

        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)theTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}

- (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}

- (void)tableView:(UITableView *)theTableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
}

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    return NO;      // The table view should not be re-orderable.
}

【问题讨论】:

标签: ipad uitableview uipopovercontroller


【解决方案1】:

是否在代码中的任何位置调用了dismissPopover:Animated,例如错误地在按钮的IBAction方法中,或者您没有IBAction方法?

【讨论】:

  • 我很赞同。很好看!谢谢你。我的 IBAction 中有这段代码
  • if (self.wholesalersPopoverController == nil){ [self performSegueWithIdentifier:@"WholesalersList" sender:self]; } else{ [self.wholesalersPopoverControllerdismissPopoverAnimated:YES]; self.wholesalersPopoverController = nil;我仍然不知道为什么 else 部分正在执行。这是因为当我评论它时它起作用了。感谢您发现 H
猜你喜欢
  • 2013-11-16
  • 2011-06-02
  • 2012-01-09
  • 2016-04-18
  • 1970-01-01
  • 1970-01-01
  • 2010-11-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多