iOS Question InputDialog function?

Filippo

Expert
Licensed User
How can you use the class UIAlertView as Inputdialog?

or these examples as "Inline Objective C code" ?
 

Erel

Administrator
Staff member
Licensed User
Here:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   NavControl.ShowPage(Page1)
End Sub

Sub Page1_Click
   Dim no As NativeObject = Me
   no.RunMethod("ShowInputDialog::", Array("This is the title", "Message"))
End Sub

Sub InputDialog_Result(Text As String)
   Log("Result: " & Text)
End Sub

#If OBJC
- (void)ShowInputDialog:(NSString*)Title :(NSString*)Message
{
  UIAlertView * alert = [[UIAlertView alloc] initWithTitle:Title
     message:Message delegate:self cancelButtonTitle:@"Hide" otherButtonTitles:nil];
   alert.alertViewStyle = UIAlertViewStylePlainTextInput;
  alert.delegate = self;
  [alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   [self.bi raiseEvent:nil event:@"inputdialog_result:" params:@[[[alertView textFieldAtIndex:0] text]]];
}
#End If
 

techknight

Well-Known Member
Licensed User
Perfect. But....

I have a few different subroutines that grab input and have different prompts, Now how to handle those in the InputDialog event? It seems there's only 1 event, so need some kind of sender or primary key to let the event know "which" subroutine I am dealing with.

I guess i could have multiple Voids, one for each subroutine.
 

techknight

Well-Known Member
Licensed User
nevermind. I just threw an integer variable in the globals and used that to track what its doing.
 

Filippo

Expert
Licensed User
Thank you Erel! :)
 
Top