这就是我展示我的popover的方式
- (IBAction)openImage:(id)sender {
OptionViewController *option = [[OptionViewController alloc] init];
option.delegate = self;
if (!popoverController) {
popoverController = [[UIPopoverController alloc] initWithContentViewController:option];
}
popoverController.delegate = self;
[popoverController setPopoverContentSize:CGSizeMake(320, 88)];
[popoverController presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
有选项视图控制器
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 2;
}
- (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] ;
}
NSInteger section = [indexPath row];
switch (section) {
case 0: // First cell in section 0
cell.textLabel.text = @"From library";
break;
case 1: // Second cell in section 1
cell.textLabel.text = @"Make a photo";
break;
default:
// Do something else here if a cell other than 1,2,3 or 4 is requested
break;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// I set breakpoints there. For now it doesn't work.
}
OptionViewController 是一个 UITableViewController (继承),它包含 UITableView 与委托和 datasource = self (对于 OptionViewController 实例)
我也使用XIB。在 XIB UITableView 中为每一侧(左、上、右、下)自动调整大小的掩码设置
在其他方法中,我不会调用任何可以锁定我的视图或其他我的操作的其他方法。
有一个带有彩色屏幕外渲染选项的屏幕截图