Skip to content

Commit

Permalink
Fix anchor and index path of ObjC popup demo (microsoft#2078)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischreiber authored Jul 29, 2024
1 parent 2d3a03b commit 6360f50
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ - (instancetype)init {
self = [super init];
if (self != nil)
{
_selectedCityIndex = [[NSIndexPath alloc] initWithIndex:0];
_selectedCityIndex = [NSIndexPath indexPathForItem:2 inSection:1];
}
return self;
}
Expand All @@ -21,7 +21,7 @@ - (void)loadView {
[super loadView];
MSFButton *demoButton = [[MSFButton alloc] initWithStyle:MSFButtonStyleOutlineAccent];
[demoButton setTitle:@"Show PopupMenu" forState:UIControlStateNormal];
[demoButton addTarget:self action:@selector(showPopupMenu) forControlEvents:UIControlEventTouchUpInside];
[demoButton addTarget:self action:@selector(showPopupMenu:) forControlEvents:UIControlEventTouchUpInside];

UIStackView *stack = [[UIStackView alloc] initWithArrangedSubviews:@[demoButton]];
[stack setAlignment:UIStackViewAlignmentTop];
Expand All @@ -41,7 +41,7 @@ - (void)loadView {
]];
}

- (void)showPopupMenu {
- (void)showPopupMenu:(id)sender {
MSFPopupMenuItem *montreal = [[MSFPopupMenuItem alloc] initWithImageName:@"Montreal"
generateSelectedImage:NO
title:@"Montréal"
Expand Down Expand Up @@ -112,9 +112,8 @@ - (void)showPopupMenu {
items:@[montreal, toronto, vancouver]];
MSFPopupMenuSection *unitedStates = [[MSFPopupMenuSection alloc] initWithTitle:@"United States"
items:@[lasVegas, phoenix, sanFrancisco, seattle]];
UIView *source = [self view];
MSFPopupMenuController *popupMenu = [[MSFPopupMenuController alloc] initWithSourceView:source
sourceRect:[source bounds]
MSFPopupMenuController *popupMenu = [[MSFPopupMenuController alloc] initWithSourceView:sender
sourceRect:[sender bounds]
presentationOrigin:-1
presentationDirection:MSFDrawerPresentationDirectionDown
preferredMaximumHeight:-1];
Expand Down

0 comments on commit 6360f50

Please sign in to comment.