2013-03-11 100 views
0

我想創造一些這樣的事:顯示按鈕的框架點擊導航控制器的動作uiitembar後

enter image description here

當在navigationcontorller(操作按鈕)右鍵框架客戶端點擊出現按鈕(如圖像)和客戶端選擇它們。通過選擇哪一個新的操作將完成。

我是一個新的iPhone和monotouch。是iphone中預定義組件的框架。如果是,它的名字是什麼,以及我如何使用它。如果它不是預定義的組件,我如何在我的應用程序中創建這樣的框架?

+0

#pragma mark - Button Methods -(void)showActionSheet { // Here is code for UIActionSheet self.actionSheet= [[UIActionSheet alloc]initWithTitle:@" " delegate:self cancelButtonTitle:@"Hide Action" destructiveButtonTitle:nil otherButtonTitles:@"Send email", @"Send message", nil]; [self.actionSheet showInView:self.view]; //self.actionSheet.tag=1; } 

添加委託方法你可以用'UIActionSheet'這個...... – Venkat 2013-03-11 12:03:23

回答

1

這是一個UIActionSheet。有一個MonoTouch sample演示如何使用它。

2

這是UIActionSheet。這裏是一個小例子:

var sheet = new UIActionSheet (""); 
sheet.AddButton ("Send email"); 
sheet.AddButton ("Send message"); 
sheet.AddButton ("Cancel"); 

sheet.CancelButtonIndex = 2; 
sheet.Clicked += delegate(object sender, UIButtonEventArgs e) { 
    if (e.ButtonIndex == 2) 
    return; 
}; 
sheet.ShowInView (this); 
+0

感謝您的回覆。不幸的是,只能選擇一個答覆作爲答案。謝謝 – 2013-03-11 12:21:00

1

添加該代碼在ViewDidLoad方法,

UIBarButtonItem *arrow = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showActionSheet)] autorelease]; 
self.navigationItem.rightBarButtonItem = arrow; 

showActionSheet方法的代碼,並添加UIActionSheet *actionSheet in .h文件,並給@property@synthesize。的UIActionSheet

#pragma mark - UIActionSheet Delegate Methods 

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
     if(buttonIndex == 0) 
    { 
     // code for selected first Button. 
    } 
    else if(buttonIndex == 1) 
    { 
     // code for selected Second Button.  
    } 
} 
+0

問題用Monotouch標記。 – petert 2013-03-11 12:14:52

+1

@petert也用obj-C標記:/ – 2013-03-11 12:29:14