iOS Question Class with Input-Dialog

D

Deleted member 103

Guest
Deleted
 
Last edited by a moderator:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Correct code:
B4X:
#If OBJC
- (void)ShowInputDialog:(NSString*)Input :(NSString*)Title :(NSString*)Message :(NSString*)OK :(NSString*)Cancel :(int)KeybardType
{
  UIAlertView * alert = [[UIAlertView alloc] initWithTitle:Title
   message:Message delegate:self cancelButtonTitle:Cancel otherButtonTitles:OK, nil];
   alert.alertViewStyle = UIAlertViewStylePlainTextInput;

   UITextField * alertTextField = [alert textFieldAtIndex:0];
   alertTextField.keyboardType = KeybardType;
   
   alertTextField.text = Input;
   alert.delegate = self;
   [alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   [self.bi raiseEvent:nil event:@"inputdialog_result::" params:@[@(buttonIndex == 1), [[alertView textFieldAtIndex:0] text]]];
}
#End If

Note that I've changed the event signature:
B4X:
Private Sub InputDialog_Result(Success As Boolean, Text As String)
     CallSub3(CallBack, mEventName & "_Result", Success, Text)
End Sub

SubExists is not required.
 
Upvote 0
Top