alexisakers / BulletinBoard

General-purpose contextual cards for iOS
MIT License
5.38k stars 304 forks source link

Buttons on Bulletin do not work #142

Open docash59 opened 5 years ago

docash59 commented 5 years ago

Problem Description: The action buttons/handlers do not work.

Steps to reproduce:

  1. Install via Pods
  2. @import BLTNBoard
  3. BLTNPageItem *page = [[BLTNPageItem alloc] initWithTitle:@"Notifications"];
    page.descriptionText = @"Receieve latest news.";
    page.actionButtonTitle = @"Allow";
    page.alternativeButtonTitle = @"Decide later";
    
    page.actionHandler = ^(BLTNActionItem * _Nonnull _item) {
        [self requestNotifications];
    };
    
    BLTNPageItem *introPage = page;
    BLTNItemManager *man = [[BLTNItemManager alloc] initWithRootItem:introPage];
    
    [man showBulletinAboveViewController:self animated:YES completion:nil];
  4. Launch the app
  5. Tap Allow on the BulletinBoard
  6. Nothing happens. Tapping the ( X ) in the top right doesn't commit any action either.

Environment:

soareseneves commented 5 years ago

This issue happens to me just sometimes, not yet sure why. I am using carthage btw.

AveryVine commented 5 years ago

Same for me - tapping the ( X ) does nothing, same with the other buttons. It looks like the BLTNItemManager is nil at the moment the ( X ) is being pressed, and thus the view can't be dismissed.

alexisakers commented 5 years ago

It is a common error for people who use the library: you need to retain the manager as a property, usually on the view controller that presents it.

artisanglobal commented 5 years ago

Another possibility... If you are overriding the setUp method, make sure you call super.setUp() or [super setUp]. This is where the action button gets wired up and if you forget to call the super method it doesn't work.

docash59 commented 5 years ago

Understood thank you. Have tried again and the BLTNBoard now works, thank you!

rlindsey2 commented 5 years ago

Can you expand on what you mean by "you need to retain the manager as a property, usually on the view controller that presents it."? Can you give some example code. I've tried doing the following on the presenting viewcontroller but that doesn't fix it. Not sure how else to do it? lazy var bulletinManager: BLTNItemManager = { let introPage = BulletinDataSource.makeIntroPage() let manager = introPage.manager return BLTNItemManager(rootItem: introPage) }()

rlindsey2 commented 5 years ago

Follow on from the above comment, this is the code of the root item: static func makeIntroPage() -> BLTNPageItem {

    let page = BLTNPageItem(title: "Boost your creativity and improve your writing ability")
    page.appearance.titleTextColor = UIColor(red: 34/256, green: 34/256, blue: 34/256, alpha: 1)
    page.appearance.titleFontSize = 25
    page.descriptionText = "Daily Prompt helps you get into the habit of creating beautiful works of art every day.\n\n\n\n"

    page.actionButtonTitle = "Continue"
    page.appearance.actionButtonColor = UIColor(red: 111/256, green: 101/256, blue: 215/256, alpha: 1)
    page.appearance.actionButtonFontSize = 22
    page.isDismissable = false

    page.actionHandler = { item in
        item.manager?.displayNextItem()
    }

    page.next = newPromptdaily()

    return page
}