2011-04-18 28 views
0
-(void)textFieldDidEndEditing:(UITextField *)textField{ 
[textInfo resignFirstResponder]; 
[self.navigationController setNavigationBarHidden:NO animated:YES]; 
informationTableView *informationtableView = [[informationTableView alloc] initWithNibName:@"informationTableView"bundle:nil]; 
UIView* MyView = informationtableView.view; 
MyView.frame = CGRectMake(12.0f, 35.0f, 260.0f, 56.0f); 

[self.view addSubview:MyView]; 

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Choisir" message:@"this gets coveredthis gets coveredthis gets coveredthis gets coveredthis gets coveredthis gets coveredthis gets coveredthis gets coveredthis gets coveredthis gets coveredthis gets coveredthis gets covered" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; 
[myAlertView addSubview:MyView]; 
[myAlertView show]; 
[myAlertView release]; 

}問題在CGRectMake爲泰伯維在AlertView

The problem TableView can not control the frame i like to get a tableView in this Alert

的問題是,所述的TableView不被框架controled。我想獲取Alert中的tableView。我怎樣才能做到這一點?

回答

1

你應該這樣做:

UIView* MyView = [[UIView alloc] initWithFrame: CGRectMake(12.0f, 35.0f, 260.0f, 56.0f)]; 
MyView.clipToBound = YES; //this ensures that the subviews are clipped by the view's frame 
[MyView addSubview:informationtableView.view]; 
[self.view addSubview:MyView]; 
+1

一般陣列解決方案是正確的,但在這種情況下,(加入的tableView到UIAlertView中),它僅僅是以「正確」的方式做一件非常糟糕的事情,有點像確保你的鞋子發亮並且你的襪子搭配在拍攝自己的腳之前:-) – Rayfleck 2011-04-18 14:56:13

+0

你有另外一個想法嗎?! – YasBES 2011-04-18 15:12:07

+0

@mike @passtissiphone nah,他只擅長類比:)) – 2011-04-18 15:31:30

1

A)我不認爲UIAlert會在其內部的tablView表現良好。你在問問題。 B)我想你想使用一個UIActionSheet,它旨在向用戶顯示一組選擇。

+0

是的,我想顯示用戶的選擇 – YasBES 2011-04-18 14:31:57