I am a green hand of iPhone development, and I just get confused about a method UIActionsheet,which is the "showInView". So what is the relation between the view who called the actionsheet and the actionsheet it self.
Actually, I wannt to customize the button in an actionsheet, so I create a class for it and overide the methods, and I want really call the methods in the superview, anybody got a solution?Thank you!
(btw, I tried the following code, but it doesn't work.)- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
{........
else if (bu开发者_如何学运维ttonIndex==sharers.count+1)
{
AddCommentViewController *parentController=(AddCommentViewController *)[self.superview nextResponder];
}
There is no public API for accessing the container, or owner of a UIActionSheet
.
You should not use the superview
property to try to get to the owner, the internal view layout for the action sheet is private and can/will change between OS updates.
If you need to get hold of the owner then add a proper property to your UIActionSheet
subclass to do this. For example:
@protocol MYActionSheetChoiceDelegate;
@interface MYActionSheet : UIActionSheet <UIActionSheetDelegate> {}
@property(nonatomic, assign) id<MYActionSheetChoiceDelegate> choiceDelegate;
@end
Notice that I name the property choiceDelegate
since the delegate
property is already taken. Now assuming your subclass is also your it's own UIActionSheetDelegate
this can be done:
-(void)actionSheet:(UIActionSheet*)sheet willDismissWithButtonIndex:(NSInteger)index;
{
if (index == SOME_INDEX) {
[self.choiceDelegate actionSheet:self didChooseSomething:index];
}
}
Change and fill the gaps to your own needs.
精彩评论