我嘗試爲iPhone創建一個應用程序,它有一個UITableViewController,每個單元格都是UITableViewCell的一個對象。每個單元格都有一個按鈕。當有人按下按鈕時,應該彈出一個彈出窗口並給他提供信息。 但是我無法管理彈出式問題,我在GitHub中查找並找到MJPopupViewController,但它提供了exc_bad_access代碼= 2錯誤。XCode5中UITableviewCell的彈出視圖
是否有任何人給我任何幫助它
我嘗試爲iPhone創建一個應用程序,它有一個UITableViewController,每個單元格都是UITableViewCell的一個對象。每個單元格都有一個按鈕。當有人按下按鈕時,應該彈出一個彈出窗口並給他提供信息。 但是我無法管理彈出式問題,我在GitHub中查找並找到MJPopupViewController,但它提供了exc_bad_access代碼= 2錯誤。XCode5中UITableviewCell的彈出視圖
是否有任何人給我任何幫助它
創建UIPopoverController財產和yourPopoverController要顯示。
self.popover=[[UIPopoverController alloc]initWithContentViewController:yourPopoverController];
self.popover.delegate=self;
寫這個代碼在按鈕單擊
[self.popover presentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem
permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
你知道iPhone不支持UIPopupcontroller,對吧? –
是的,我認爲他用於iPad應用程序,他沒有進入,無論他在之前使用的iPad或iPhone。 –
由於佐尼的想法,你可以使用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
}
是的,這就是我要找的!謝謝寶貝:D – VietHung
iPhone app or i墊? –
請提供有關此問題的更多信息。 –