[关于协议界面的问题][ios]

96
LPTableView
2016.05.12 11:51* 字数 526



开发要求:

联网的时候,有协议数据的时候从上往下弹出界面,每个用户必须同意协议才能使用app,否则退出应用(exit(0));

我的解决方案:在comment类里,写个类方法,实现

if (![[NSUserDefaults standardUserDefaults] boolForKey:@"showUserAgreementViewController"]) {

CATransition *transition = [CATransition animation];

transition.duration = 0.3f;

transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

transition.type = kCATransitionMoveIn;

transition.subtype = kCATransitionFromBottom;

[ESControllerManager pushViewController:@"ESUserAgreementViewController" Parameters:@{@"title":daRenAgreementTitle,@"content":daRenAgreementContent,@"ID":@(daRenAgreementID)} Animated:NO];

[[ESControllerManager getRootNavigationController].view.layer addAnimation:transition forKey:nil];

}

});

bug:

1,当手机没电,强制关机等突然中止应用的时候,再此打开应用时,协议不能弹出;

为防止界面弹出多次,我在本地保存一个bool值,标示界面是否在弹出boolForKey:@"showUserAgreementViewController",问题就在这里,如果突然中止应用,这个bool值还是yes,界面如何能弹出来呢

2,当登陆应用的时候,弹出主页,协议不弹出;

这种情况,主界面第二次弹出还带有动画,其实还是蛮好玩的,这个问题是在push上,当两个界面同时弹出时,一个界面覆盖另一个界面,显示出来的界面就有一定的不确定行

解决方案:

应用代码:

if (![ESUserAgreementViewController IsShow]) {

[ESUserAgreementViewController Show:daRenAgreementTitle Content:daRenAgreementContent ID:daRenAgreementID];

}

界面搭建:将界面放到一个window上,界面是否弹出标示 设置成静态变量

static UIWindow* window;

static BOOL isShow;

@implementation ESUserAgreementViewController

+(BOOL)IsShow

{

return isShow;

}

+(void)Init

{

if(!window)

{

window=[[UIWindow alloc]initWithFrame:CGRectMake(0, 0, ESWidth, ESHeight)];

window.windowLevel=1499.9;

window.hidden=YES;

[window makeKeyAndVisible];

}

}

+(void)Show:(NSString*)title Content:(NSString*)content ID:(int)ID

{

isShow=YES;

[ESUserAgreementViewController Init];

ESUserAgreementViewController* viewController=[[ESUserAgreementViewController alloc]init];

[viewController setParameters:@{@"title":title,@"content":content,@"ID":@(ID)}];

for (UIView* view in window.subviews) {

[view removeFromSuperview];

}

[window setRootViewController:viewController];

[window addSubview:viewController.view];

window.frame=CGRectMake(0, -ESHeight, ESWidth, ESHeight);

window.hidden=NO;

[UIView animateWithDuration:0.3 animations:^{

window.frame=CGRectMake(0, 0, ESWidth, ESHeight);

}];

}

+(void)Hide

{

isShow=NO;

[UIView animateWithDuration:0.3 animations:^{

window.frame=CGRectMake(0, -ESHeight, ESWidth, ESHeight);

}];

}

日记本