开发者

password protecting a button in my ipad app

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜