2011-10-11 97 views

回答

0

也许你想设置YourTableView.userInteractionEnabled = NO?

-1

您可以停止滚动表格视图。但是你不应该在scrollview中添加tableview。 UITableView是UIScrollView的子类,在另一个上添加一个scrollView会产生问题。我建议你删除scrollview并单独使用tableview(因为tableview本身是一个滚动视图)。

0

是的,我们可以禁用滚动tableview。 转到 - > xib->选择表格 - >转到第一个选项卡 - >取消选择滚动启用。

第二个问题的答案。

将UiView放在您的表格的页脚中,然后将该按钮放置在您想要显示在底部的UIView中。它将始终显示在底部。

如果要以编程方式放置按钮,请在viewDidload方法中使用以下代码。

 ///--------Table Footer is Set here 

    UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 260, 44)]; 
    UIButton *adddays = [[UIButton alloc] initWithFrame:CGRectMake(10, 0, 260, 44)]; 
    [adddays setBackgroundImage:[UIImage imageNamed:@"abcd.png"] forState:UIControlStateNormal]; 
    [adddays addTarget:self action:@selector(buttonaction) forControlEvents:UIControlEventTouchDown]; 
    UILabel *text = [[UILabel alloc] initWithFrame:CGRectMake(75, 12, 250, 20)]; 
    [text setBackgroundColor:CLEAR_COLOR]; 
    [text setText:@"Title for your button"]; 
    [text setTextColor:XDARK_BLUE]; 
    text.font=[UIFont fontWithName:@"Arial-BoldMT" size:18.0f]; 

    [footer addSubview:adddays]; 
    [footer addSubview:text]; 
    [table setTableFooterView:footer]; 
0

这是假设你已经创建IBOutlets您scrollViewtableViewbutton,并适当地勾搭起来。

我觉得它有用要记住,我们只用一个CGRectorigin.y & size.height)y值搞乱 - 的x值应在厦门国际银行成立。

我评论这个满头来说明我的好点,通常我只会意见,并酌情

-(void)viewDidLoad { 
[self.tableView setScrollEnabled:NO]; 

// Get the number of rows in your table, I use the method 
// 'tableView:numberOfRowsInSection:' because I only have one section. 

int numOfRows = [self.tableView numberOfRowsInSection:0]; 

// Get the height of your rows. You can use the magic 
// number 46 (44 without including the separator 
// between rows) for the height of your rows, but because 
// I was using a custom cell, I had to declare an instance 
// of that cell and exctract the height from 
// cell.frame.size.height (adding +2 to compensate for 
// the separator). But for the purpose of this demonstration 
// I'm going to stick with a magic number 

int rowHeight = 46; //Eww, Magic numbers! :/ 

// Get a reference to the tableViews frame, and set the height 
// of this frame to be the sum of all your rows 

CGRect frame = self.tableView.frame; 
frame.size.height = numOfRows * rowHeight; 

// Now we have a frame with the exact size of our table, 
// so set the 'tableView.frame' AND the 'tableView.contentSize' 
// to that. (Because we want ALL rows visible as you 
// disabled scrolling for the 'tableView') 

self.tableView.frame = frame; 
self.tableView.contentSize = frame.size; 

// Now we want to set up the button beneath the table. 
// We still have the 'frame' variable, which gives us 
// the tableView's Y-origin and height. We just add these 
// two together (with +20 for padding) to get the origin of the button 

CGRect buttonFrame = self.button.frame; 
buttonFrame.origin.y = frame.origin.y + frame.size.height + 20; 
self.button.frame = buttonFrame; 

// Finally, we want the `scrollView`'s `contentSize` to 
// encompass this entire setup (+20 for padding again) 

CGRect scrollFrame = self.scrollView.frame; 
scrollFrame.size.height = buttonFrame.origin.y + buttonFrame.size.height = 20; 
self.scrollView.contentSize = scrollFrame.size; 
}