开发者

Added buttons, webview, added outlets, but can't play with them in the code

I made a toolbar with two buttons on it. I then created two outlets in my class controller. Then I hooked the the controller to the buttons and selected the outlets.

Finally I rewritten the class files (that added:

IBOutlet id next;
IBOutlet id previous;

to my .h file).

So now, everything looks okay. But then I try somewhere in the code to change the state of one of my button like this:

next.enabled = YES;

I tried with self. too but unfortunately I receive this error message: error: request for member 'enabled' in something not a structure or union

Do you have any idea of what's happening there?

And yes I have:

#import <UIKit/UIKit.h>

:)

Using:

[next setEnabled:YES];

gives me no error but still doesn't work...

And finally, for documenting purposes here's the whole method:

- (void)viewDidLoad {
    [super viewDidLoad];

     if (!self.currentLevel) {
          self.currentLevel = @"1";
     }

     NSArray *etape = [self.etapes objectForKey:self.currentLevel];
     if ([etape count] > 0) {
          self.navigationItem.开发者_开发知识库title = [etape objectAtIndex:1];
          if ([etape count] > 1) {
               [next setEnabled:YES];
          }

     } else {
          self.navigationItem.title = @"Aucune étape";
     }
}

When I do:

NSLog(@"%@", [next class]);

It returns (null) ... I guess it is supposed to be UIBarButtonItem...

It seems that it is impossible to play with any outlets even if I don't receive any errors while playing with them...


That should be:

IBOutlet UIButton * next;
IBOutlet UIButton * previous;


I'm not sure about the iphone SDK because I don't use it, but you enable/disable toolbar items using the following method. I usually use the button's label to identify which button I target.

-(BOOL)validateToolbarItem:(NSToolbarItem*)theItem {
    BOOL shouldEnable = YES;
    NSString* itemLabel = [theItem label];
    if ([itemLabel isEqualToString:@"next"]) {
        shouldEnable = NO;
    }
    return shouldEnable;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜