已更新 -有一个应用程序,显示供用户选择的文件列表;文件列表位于UIPopover中的UITableView中。这是显示文件列表内容的UIPopover的代码;预计用户将选择其中一个文件,在该文件处处理将继续。眼下,处理继续没有用户选择从列表中,这是没有意义的文件(无法处理文件,除非我知道要处理的文件!):如何阻止执行,直到用户选择在UIPopover中的UITableView中的行?
-(void)browseDirectory {
CommonMethods *cm = [[CommonMethods alloc]init];
fileList = [cm listContentsOfDirectory];
// format popover to display fileList
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 340, 400)];
popoverView.backgroundColor = UIColorFromRGB(0xFFF9AF);
popoverContent.view = popoverView;
//resize the popover view shown in the current view to the view's size
popoverContent.preferredContentSize = CGSizeMake(340, 400);
// create a UITableView to display the contents of the array
UITableView *tableView = [[UITableView alloc] initWithFrame:popoverView.frame style:UITableViewStylePlain];
// must set delegate & dataSource, otherwise the the table will be empty and not responsive
tableView.delegate = self;
tableView.dataSource = self;
// add to canvas
[popoverView addSubview:tableView];
// if previous popoverController is still visible... dismiss it
if ([popoverController isPopoverVisible])
[popoverController dismissPopoverAnimated:YES];
//create a popover controller
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
[popoverController presentPopoverFromRect:((UIButton *)oUpload).frame inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
// number of section(s), now I assume there is only 1 section
- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView {
return 1;
}
// number of row in the section, I assume there is only 1 row
- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section {
return fileList.count;
}
// the cell will be returned to the tableView
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"FilenameCell";
UITableViewCell *cell = (UITableViewCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = fileList[indexPath.row];
return cell;
}
这是代码,其中-browseDirectory被称为:
[self browseDirectory]; // drops through!
if(cbvABE.checked == YES) { // tab-delimited
[self createTabExportFile: @"ABE"]; {
cbvEmailABE.checked? [self sendViaEmail:@"ABE"]:[self uploadToABE];
}
}
的问题是:我该如何防止(或块)的持续后,我打电话-browseDirectory直到用户在选定的UITableView行执行?
我不明白你需要什么。你有一些代码,你需要解释它的作用 - 没有人想读一段代码而没有解释 - 而你想要的东西,但你没有描述你想要什么,什么出了问题。请更新您的问题以获取更多信息 – 2014-10-05 19:22:56
澄清问题;请删除倒票。 – SpokaneDude 2014-10-05 20:58:12
已删除。现在就回答它。 – 2014-10-05 20:59:17