gpt4 book ai didi

ios - XCode5 中 UITableviewCell 的弹出 View

转载 作者:行者123 更新时间:2023-11-29 03:07:09 25 4
gpt4 key购买 nike

我尝试为iPhone制作一个应用程序,它有一个UITableViewController,每个单元格都是UITableViewCell的一个对象。每个单元格都有一个按钮。当有人按下按钮时,应该会出现一个弹出窗口并为他提供信息。但是我无法管理弹出窗口问题,我在 GitHub 中查找并找到 MJPopupViewController但它给出了 exc_bad_access code=2 错误。

有人帮我解决吗

最佳答案

按照 Johny 的想法,您可以使用 UIPopoverController:

   @interface YourViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *imgSquare;
@property (strong, nonatomic) UIPopoverController *popover;
@end

@implementation YourViewController

- (void)viewDidLoad
{
[super viewDidLoad];
UIViewController *yourController;
self.popover = [[UIPopoverController alloc] initWithContentViewController:yourController];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(showPopover)
name:@"yourNotificationName"
object:nil];
// Do any additional setup after loading the view, typically from a nib.


}

- (void)showPopover
{
[self.popover presentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem
permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:@"yourNotificationName"
object:nil];
}

然后每当点击 CustomTableViewCell 中的按钮时发布通知

- (void)buttonTapped
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"yourNotificationName"
object:self];
//do anything
}

关于ios - XCode5 中 UITableviewCell 的弹出 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22636039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com