AlertView中用于TAbleView的CGRectMake中的问题

时间:2011-04-18 14:22:13

标签: iphone objective-c

-(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];

}

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

问题是TableView不受帧控制。我想在Alert中获取tableView。我怎样才能做到这一点?

2 个答案:

答案 0 :(得分:1)

A)我不认为UIAlert在其中有一个tablView会表现得很好。你在找麻烦。 B)我认为您想要使用UIActionSheet,它旨在向用户显示一系列选择。

答案 1 :(得分: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];