iphone - 第一 View 警报

标签 iphone ios uialertview

<分区>

我有两个 textfields ,

  1. 个人资料名称
  2. 个人简介

在我的应用程序主屏幕中,我想在第一次启动时显示一个警报 View “创建配置文件”。如果在下一个启动配置文件中存在它不应该显示警报 View ?有人可以帮我编码吗?

最佳答案

好的,我需要做同样的事情。我创建了一个用于存储 NSUserDefaults 的单例类。

我称它为我的默认类。

默认.h

#import <Foundation/Foundation.h>

@interface Defaults : NSObject
{

}
@property(atomic,assign) int numberOfLaunches; 
+(Defaults*) currentDefaults;
+(Defaults*) defs;

默认.m

#import "Defaults.h"
#include "SynthesizeSingleton.h"
@implementation Defaults

SYNTHESIZE_SINGLETON_FOR_CLASS(Defaults)

+(Defaults*) defs
{
return [Defaults currentDefaults];
}

-(int) numberOfLaunches
{
    return [[NSUserDefaults standardUserDefaults] integerForKey:@"number_of_launches"];
}
-(void) setNumberOfLaunches:(int)numOfLaunch
{
    [[NSUserDefaults standardUserDefaults] setInteger:numOfLaunch forKey:@"number_of_launches"];
}

--现在只需将默认类导入您要在其中使用它的任何类。

if([Defaults defs].numberOfLaunches < 1)
    {                                                      
            [Defaults defs].numberOfLaunches++;
            //Perform whatever alertView action your wanting to do

              UIAlertView *alertV=[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"FIrst Launch",NULL) message:NSLocalizedString(@"This is the apps first launch",NULL) delegate:nil cancelButtonTitle:NSLocalizedString(@"Okay",NULL) otherButtonTitles:nil];
        [alertV show];
        [alertV release];


   }

//如果你想知道他们按下了哪个按钮,你需要采用UIAlertViewDelegate

关于iphone - 第一 View 警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12594442/

相关文章:

iphone - 如何在 iPhone 中保存或捕获图像时降低图像分辨率和内存大小

iphone - 如何将 UITableView 添加到 UIView 中?

ios - 使用 Firebase 扁平化数据

ios - 显示警报时出错

ios - UIAlertViews、UIActionSheets 和 keyWindow 问题

objective-c - UIAlertController 延迟显示

ios - 在 iPhone 上的弹出窗口中呈现 UIAlertController ActionSheet

iphone - 属性 txtname (uiTextView *) 的类型与 ivar txtname(uiTextView) 不匹配

iphone - 如何在放大点向 UIView 添加按钮?

ios - Device Ready 未在 Adob​​e Phonegap Build 中触发