创建一个 NSObject 类buttonPanel
并分配按钮,您可以按如下方式调用按钮面板:
buttonPanel * buttonPanel = [[buttonPanel alloc] init];
buttonPanel.delegate = self;
[buttonPanel showButtonWithNavigationController:self.navigationController inView:self.parentViewController.view];
按钮面板类:
//ButtonPanel.h
#import <Foundation/Foundation.h>
@class ButtonPanel;
@protocol ButtonPanelDelegate <NSObject>
-(void) ButtonPanel:(ButtonPanel*) buttonPanel ;
@end
@interface ChatMessagePanel : NSObject<UIActionSheetDelegate> {
UINavigationController *navigationController;
id<ButtonPanelDelegate> delegate;
}
@property(nonatomic,retain) UINavigationController *navigationController;
@property (nonatomic,retain) id<ButtonPanelDelegate> delegate;
-(void)showButtonWithNavigationController:(UINavigationController*) navigationController inView:(UIView*) view;
@end
// ButtonPanel.m
#import "ChatMessagePanel.h"
@implementation ButtonPanel
@synthesize userListModal,delegate,navigationController;
-(void)showMessageWithNavigationController:(UINavigationController*) _navigationController inView:(UIView*) view
{
self.navigationController = _navigationController;
baseViewWidth = view.frame.size.width;
baseViewHeight = view.frame.size.height;
incomingRequestActionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil, nil];
[incomingRequestActionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[incomingRequestActionSheet showInView:view];
UIButton *blockUserBttn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
[blockUserBttn setTitle:NSLocalizedString(@"BLOCK_USERS",@"") forState:UIControlStateNormal];
[blockUserBttn setBackgroundColor:[UIColor clearColor]];
[blockUserBttn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *blockUserBarBttn = [[UIBarButtonItem alloc] initWithCustomView:blockUserBttn];
[optionToolBar setItems:[NSArray arrayWithObjects:blockUserBarBttn, nil]];
[incomingRequestActionSheet addSubview:optionToolBar];
}
-(void)buttonAction:(id) sender
{
}
@end