我有一个视图,它有一个选项全屏视图,我已经在switchcontroller的帮助下完成了编码,但是在全屏切换到开启并重定向到另一个页面并返回后,它更改为默认屏幕而不是全屏而没有swithcoff switchcontroller,所以我把NSUserDefault用于存储值,但没有运气这是我的代码
-(IBAction)_clickbtnfullscreen:(id)sender
{
if(switchcontrolsplitf.on){
[switchcontrolsplitf setOn:YES animated:YES];
//i put here the nsuserdeafult
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"fullscreenn"];
CGRect frame = tab.frame;
CGRect imageframe = btnShowHide.frame;
CGRect viewframe = hideviewoftab.frame;
CGRect lblframe = _lblshowhide.frame;
CGRect lblmalframe = _lblmalaylan.frame;
CGRect viewwframee= sliderView.frame;
if (!self.isExpandedfullscreen)
{
btnShowHide.enabled = NO;
switchcontrolsplitf.enabled =YES;
tab.scrollEnabled=YES;
self.isExpandedfullscreen = YES;
table.frame = CGRectMake(4, 48, 311, 20);
if (frame.origin.y -=420) {
tab.frame = frame;
}
if (imageframe.origin.y -=420) {
btnShowHide.frame =imageframe;
}
if (viewframe.origin.y -=420) {
hideviewoftab.frame =viewframe;
}
if (lblframe.origin.y -=420) {
_lblshowhide.frame =lblframe;
}
if (viewwframee.origin.y -=420) {
sliderView.frame =viewwframee;
}
if (lblmalframe.origin.y -=420) {
_lblmalaylan.frame =lblmalframe;
}
}
}
else
{
CGRect frame = tab.frame;
CGRect imageframe = btnShowHide.frame;
CGRect viewframe = hideviewoftab.frame;
CGRect lblframe = _lblshowhide.frame;
CGRect lblmalframe = _lblmalaylan.frame;
CGRect viewwframee= sliderView.frame;
self.isExpandedfullscreen = NO;
[switchcontrolsplitf setOn:NO animated:YES];
//[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"lowlight"];
tab.scrollEnabled=NO;
switchcontrolsplitf.enabled =YES;
table.frame = CGRectMake(4, 48, 311, 387);
btnShowHide.enabled = YES;
if (frame.origin.y +=420) {
tab.frame = frame;
}
if (imageframe.origin.y +=420) {
btnShowHide.frame =imageframe;
}
if (viewframe.origin.y +=420) {
hideviewoftab.frame =viewframe;
}
if (lblframe.origin.y +=420) {
_lblshowhide.frame =lblframe;
}
if (viewwframee.origin.y +=420) {
sliderView.frame =viewwframee;
}
if (lblmalframe.origin.y +=420) {
_lblmalaylan.frame =lblmalframe;
}
}
在viewwillappear中
- (void)viewWillAppear:(BOOL)animated{
BOOL fullscreenn = [[NSUserDefaults standardUserDefaults] boolForKey:@"fullscreenn"];
if (fullscreenn) {
[switchcontrolsplitf setOn:YES animated:YES];
}
如何解决这个问题。请帮助我。 感谢
答案 0 :(得分:2)
设置值后,您需要synchronize即保存
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"fullscreenn"];
[[NSUserDefaults standardUserDefaults] synchronize];