相关疑难解决方法(0)

iPhone上的UIAlertView中的UITextField - 如何使其响应?

我将UITextField放入UIAlertView并将其向上移动,以便键盘不会使用以下代码覆盖它:

[dialog setDelegate:self];
[dialog setTitle:@"Enter Name"];
[dialog addButtonWithTitle:@"Cancel"];
[dialog addButtonWithTitle:@"OK"];
UITextField * nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setBackgroundColor:[UIColor whiteColor]];
[dialog addSubview:nameField];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, 100.0);
[dialog setTransform: moveUp];
[dialog show];
Run Code Online (Sandbox Code Playgroud)

我还有以下代码来处理警报视图:

- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex{    
    NSLog(@"%d", (int) buttonIndex);
    if (buttonIndex == 1) { // OK pushed
        NSLog([alert textField].text); // does not log anything
    } else {
        // Cancel pushed
}}
Run Code Online (Sandbox Code Playgroud)

我还有一个UIAlertViewExtended.h文件,其中包含:

@class UITextField, UILabel;

@interface UIAlertView(Extended)

-(UITextField *)textField;

@end
Run Code Online (Sandbox Code Playgroud)

我的问题是如何获取用户输入的文本以及如何解除键盘?

谢谢,本

iphone cocoa-touch

24
推荐指数
4
解决办法
5万
查看次数

Xcode:在applicationDidBecomeActive中显示登录视图

在我的应用程序中,我想显示一个登录屏幕 - 当应用程序启动时以及应用程序变为活动状态时将显示该屏幕.作为参考,我使用的是故事板,ARC,它是一个标签栏应用程序.

因此,我需要在方法中执行以下过程applicationDidBecomeActive:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    if ( ... ) { // if the user needs to login
        PasswordViewController *passwordView = [[PasswordViewController alloc] init];
        UIViewController *myView = self.window.rootViewController;
        [myView presentModalViewController:passwordView animated:NO];
    }
}
Run Code Online (Sandbox Code Playgroud)

在某种程度上这确实有效 - 我可以调用一个方法,viewDidAppear其中显示一个警报视图以允许用户登录.但是,这是不可取的,我想有一个登录文本框和其他ui元素.如果我不调用我的登录方法,即使我在视图上放置了标签和其他元素,也没有任何反应并且屏幕保持黑色.

有谁知道解决这个问题的方法?我的密码视图嵌入在导航控制器中,但与主故事板分离.

iphone xcode objective-c ios

5
推荐指数
1
解决办法
6819
查看次数

iPhone iOS如何在应用程序从后台恢复时添加pin/passcode锁屏?

我需要添加一个4位数的引脚视图控制器,它将"悬停"在我的应用程序的主窗口上,并防止不知道该引脚的用户浏览应用程序中的数据.

我很感兴趣,如果有任何演示项目或开源项目完成此功能(按键点击,自动更改焦点,显示静态光泽键盘,锁定x秒后).

谢谢您的意见!

security iphone uiview ios

4
推荐指数
2
解决办法
6985
查看次数

标签 统计

iphone ×3

ios ×2

cocoa-touch ×1

objective-c ×1

security ×1

uiview ×1

xcode ×1