<分区>
我有两个 textfields
,
- 个人资料名称
- 个人简介
在我的应用程序主屏幕中,我想在第一次启动时显示一个警报 View “创建配置文件”。如果在下一个启动配置文件中存在它不应该显示警报 View ?有人可以帮我编码吗?
标签 iphone ios uialertview
<分区>
我有两个 textfields
,
在我的应用程序主屏幕中,我想在第一次启动时显示一个警报 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/