I've added a method to the UIAlert view so that it can use it's "Popover" feature to be displayed as a popup for a button for example (i.e. with an arrow pointing to the "popup" component)
(only available on iPads)
Simply call the overloaded "Execute" method with a "popoverControl" parameter to use the new feature.
This shouldn't break any existing code but who knows :-)
Then I've made the following changes to the implementation...
functionTDPFUIActionSheet.Execute: TModalResult;beginResult:=Execute(nil);end;functionTDPFUIActionSheet.Execute(APopoverControl: TControl):TModalResult;{$IFDEFIOS}varAlertView: UIAlertView;RunLoop: NSRunLoop;DistantFuture: NSDate;DefaultRunLoopMode: NSString;{$ENDIF}beginFPopoverControl:=APopoverControl;{$IFDEFIOS}FDPFActionSheetDelegate.FModal:=True;ShowMessage;RunLoop:=TNSRunLoop.Wrap(TNSRunLoop.OCClass.currentRunLoop);DistantFuture:=TNSDate.Wrap(TNSDate.OCClass.distantFuture);DefaultRunLoopMode:=NSDefaultRunLoopMode;whileFDPFActionSheetDelegate.ModalandRunLoop.runMode(DefaultRunLoopMode,DistantFuture)do;Result:=FDPFActionSheetDelegate.ModalResult;{$ENDIF}end;procedureTDPFUIActionSheet.ShowMessage;{$IFDEFIOS}varI,idx: Integer;p: Pointer;LView: UIView;ARect: NSRect;{$ENDIF}begin{$IFDEFIOS}// this function is not re-entry safe - have to kill the previous messageifFMessageView<>nilthenbeginFMessageView.dismissWithClickedButtonIndex(FMessageView.cancelButtonIndex,False);FMessageView:=nil;end;FMessageView:=TUIActionSheet.Wrap(TUIActionSheet.Alloc.initWithTitle(NSStr(''),nil,nil,nil,nil));FMessageView.setDelegate(FDPFActionSheetDelegate.GetObjectID);FMessageView.setActionSheetStyle(UIActionSheetStyleDefault);forI:=0toButtons.Count-1dobeginidx:=FMessageView.addButtonWithTitle(NSStr(Buttons[I].Title));ifButtons[I].ButtonKind=bkCancelthenFMessageView.setCancelButtonIndex(idx)elseifButtons[I].ButtonKind=bkDestructivethenFMessageView.setDestructiveButtonIndex(idx);end;ifButtons.Count=0thenbeginFUITapGestureRecognizer.setNumberOfTapsRequired(1);FUITapGestureRecognizer.setNumberOfTouchesRequired(1);FUITapGestureRecognizer.setDelaysTouchesBegan(true);FUITapGestureRecognizer.setDelaysTouchesEnded(false);FMessageView.addGestureRecognizer(FUITapGestureRecognizer);end;FMessageView.setTitle(NSSTR(Title));LView:=nil;ifAssigned(GetSharedApplication.keyWindow.rootViewController)thenLView:=GetSharedApplication.keyWindow.rootViewController.view;ifLView=nilthenbeginp:=GetSharedApplication.keyWindow.subviews.objectAtIndex(0);ifAssigned(p)thenLView:=TUIView.Wrap(p);end;if(FPopoverControl<>nil)and(IsIPad)thenbeginARect.origin.x:=FPopoverControl.AbsoluteRect.Left;ARect.origin.y:=(FPopoverControl.AbsoluteRect.Top)+GetSharedApplication.statusBarFrame.size.height;ARect.size.width:=FPopoverControl.Width;ARect.size.height:=FPopoverControl.Height;FMessageView.showFromRect(ARect,LView,True);endelseFMessageView.showInView(LView);{$ENDIF}end;
Last edit: Graham 2015-01-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi guys,
I've added a method to the UIAlert view so that it can use it's "Popover" feature to be displayed as a popup for a button for example (i.e. with an arrow pointing to the "popup" component)
(only available on iPads)
Simply call the overloaded "Execute" method with a "popoverControl" parameter to use the new feature.
This shouldn't break any existing code but who knows :-)
Here are the changes...
Then I've made the following changes to the implementation...
Last edit: Graham 2015-01-21
Just edited the above due to a compile error. Fixed now :-)
Hi Graham,
Thank you for good work,
Please attach DPF.iOS.UIActionSheet.pas full source code file,
Regards.
Sure, here you are.
Graham
Hi Graham
Thank you again,
I will put it in SVN directory after it's working ! :)
Regards
Hi Babak,
Please could you integrate the above change into the SVN so I don't overwrite my changes here.
Thanks,
Graham
Hi Graham,
SVN, Updated.
Thank you for this good job,
Regards