已更新 -有一個應用程序,顯示供用戶選擇的文件列表;文件列表位於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