I created unbutton programmatically in a function and now i want to disable it from another function in ViewController in iOS Objective C.
-(void)makeButton{
self.markerButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIImage *markerImage = [UIImage imageNamed:markerImageName];
self.markerButton.frame = CGRectMake((self.mView.bounds.size.width/2)-(markerImage.size.width/2), (self.mView.bounds.size.height/2)-(markerImage.size.height), markerImage.size.width, markerImage.size.height);
self.markerButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
[self.markerButton setTitle:@"" forState:UIControlStateNormal];
self.markerButton.btnData = self.markerButton;
[self.markerButton setBackgroundImage:[UIImage imageNamed:markerImageName] forState:UIControlStateNormal];
[self.markerButton addTarget:self action:@selector(markerButtonClicked:forEvent:) forControlEvents:UIControlEventTouchUpInside];
[self.mView addSubview:self.markerButton];
-(void)anotherFunction{
self.markerButton.enable = NO;
}
You should simply change self.markerButton.enable = NO;
to self.markerButton.userInteractionEnabled=NO;