NSObject クラスbuttonPanel
を作成してボタンを割り当てると、次のようにボタン パネルを呼び出すことができます。
buttonPanel * buttonPanel = [[buttonPanel alloc] init];
buttonPanel.delegate = self;
[buttonPanel showButtonWithNavigationController:self.navigationController inView:self.parentViewController.view];
ButtonPanel クラス:
//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