开发者

password protecting a button in my ipad app

开发者 https://www.devze.com 2023-02-15 12:19 出处:网络
This is a strange requirement. I am developing an app where there is a开发者_开发百科 button, and after clicking it, will take it to a configuration screen. This is to be only used by the administrato

This is a strange requirement. I am developing an app where there is a开发者_开发百科 button, and after clicking it, will take it to a configuration screen. This is to be only used by the administrators. Can this button be password protected? If yes any sample code would help.

Let me know if you need more details.

-Pradeep


I don't know if there is any other simpler way to do it. So here is my solution.
You can check weather the user is an administrator or not in the code during viewDidLoad and then make the Button hidden if the user is not an administrator.

PS. You need to have an IBOutlet for that button in your class file.


I am not quite sure how you wish to password protect your button. But I have one solution which (I hope) can help.

- (IBAction)proceedToFirstWindow:(id)sender {

[window2 makeKeyAndOrderFront:self];


}

- (IBAction)proceedToSecondWindow:(id)sender {


if ([[secureField stringValue]isEqualToString:@"hello"]) {

    [window orderOut:self];

    [window2 orderOut:self];

    [window3 makeKeyAndOrderFront:self];

}
else {
    return;
}
}

When the user presses your button it would display a new window. This "new" window would contain a NSSecureTextField where the user has to type the correct password to proceed, in this case, to another window. I am not quite sure how this would work on the ipad, maybe there is something similar? I hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消