Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 1.66 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Hidden Button Saving
  2. -(IBAction)Act1 {
  3. Act1Button.hidden = YES;
  4. }
  5.  
  6. -(IBAction)De1 {
  7. Act1Button.hidden = NO;
  8. }
  9.  
  10.  
  11. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  12. {
  13. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  14. if (self) {
  15.     // initialization
  16. }
  17. return self;
  18. }
  19.  
  20.  
  21. - (IBAction)savedata:(id)sender
  22. {
  23.  
  24. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  25.  [defaults setValue:@"myValue" forKey:@"mykey"];
  26. [defaults synchronize];
  27.  
  28. }
  29.  
  30.  
  31. - (void)viewDidLoad
  32. {
  33. NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
  34. if (![userDefaults valueForKey:@"mykey"]) {
  35.     [userDefaults setValue:@"myValue" forKey:@"mykey"];
  36.     NSLog(@"setting value");
  37. }
  38. [userDefaults synchronize];
  39.  
  40. }
  41.  
  42.  
  43. - (void)viewDidUnload
  44. {
  45. [super viewDidUnload];
  46. // Release any retained subviews of the main view.
  47. }
  48.  
  49. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  50. {
  51. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  52. }
  53.  
  54. @end
  55.  
  56. '@interface testViewController : UIViewController
  57. {
  58. IBOutlet UIButton *Act1Button;
  59. IBOutlet UIButton *De1Button;
  60.  
  61. }
  62.  
  63.  
  64. @property (retain, nonatomic) IBOutlet UIButton *Act1Button;
  65. @property (retain, nonatomic) IBOutlet UIButton *De1Button;
  66.  
  67.  
  68. - (IBAction)Act1;
  69. - (IBAction)De1;
  70.  
  71. -(IBAction)savedata:(id)sender;
  72.  
  73.  
  74. @end`
  75.        
  76. -(IBAction)Act1 {
  77.   Act1Button.hidden = YES;
  78.   NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  79.   [defaults setValue:Act1Button.hidden forKey:@"act1buttonState"];
  80. }
  81.  
  82. - (void)viewDidLoad {
  83.   NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
  84.   Act1Button.hidden = [userDefaults valueForKey:@"act1buttonState"];
  85. }