tags:

views:

352

answers:

1

I need to disable the buttons in UIActionSheet. after some operations i need to enable them again. So is there a way to do this.

Thanks

A: 

Thees buttons are subviews of UIActionSheet and their class is UIThreePartButton

You can get them and do all that you want:

UIActionSheet *a = [[UIActionSheet alloc]initWithTitle:@"" delegate: nil cancelButtonTitle: @"c" destructiveButtonTitle: @"d" otherButtonTitles: @"ot", nil];
    [a showInView: window];

    for(UIView *v in [a subviews])
    {
     if([[v description] hasPrefix: @"<UIThreePartButton"] )
     {
      v.hidden = YES;  //hide
           //((UIButton*)v).enabled = NO;   // disable

     }
    }
oxigen
I would suggest you do not use this method as these are private to the SDK. Apple might reject your app. The best alternative would be to not show these buttons at all instead of disabling them
lostInTransit
There is no private methods in this code )) Only public :)Sometimes I use private methods in my apps. I use them once-twice in application and apple didn't reject these apps
oxigen
It's not just getting rejected by Apple, use of private API shows a lack of respect for your customers. Private API are private because Apple is still locking them down, so if and when they change, your application will break. View traversal like you described above caused a number of applications to break under 3.0, so much so that Apple called this out in the release notes and said not to do this.
Brad Larson