我對iphone開發非常陌生,我想減小分組表格視圖中的部分大小,即減小部分的寬度。怎麼能提前實現 感謝在tableview中減小部分的大小
回答
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return kHeightForHeaderInSection;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
// wrapperView - by default has the width of the table, you can change the height
// with the heightForHeaderInSection method
UIView *aView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
// your real section view: a label, a uiview, whatever
CGRect myFrame; // create your own frame
myFrame.origin = CGPointMake(10, 0);
myFrame.size = CGSizeMake(tableView.bounds.size.width-10,kHeightForHeaderInSection);
UILabel *label = [[[UILabel alloc] initWithFrame:myFrame] autorelease];
label.text = @"myText"
[aView addSubview:label];
return aView;
}
可否請您詳細說明您的上述方法,我沒有得到它.. – sujay 2011-05-21 12:14:50
在您的tableView委託中您需要實現上述方法。 viewForHeaderInSection返回一個視圖(讓我們調用myView),其高度等於heightForHeaderInSection返回的值,width等於tableView寬度。在這一點上,你可以創建和添加你自己定義的框架的目標視圖(即標籤),並將其添加到myView。另一種方法是繼承UILabel方法: - textRectForBounds:limitedToNumberOfLines:和-drawTextInRect :. – marcio 2011-05-21 14:06:29
嗨添加此的UITableViewDelegate方法
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return height;
}
我想設置寬度每一行都不是高度.. – sujay 2011-05-21 12:19:09
它的一個非常簡單的SOLN ......上 「的UITableViewDelegate」
@interface MyController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableview *myTableview;
只需右鍵點擊和「UITableViewDataSource」
n實現所有委託。 ..u會在那裏找到所有類型的調整....天氣你想改變或調整高度或寬度的部分或行...或多少部分或多少行在一個部分你想要.... 其簡單的n自動調用....問候
右擊n去定義.... – namannam 2011-05-21 15:33:33
- 1. 如何減小窗口的按鈕部分的大小extjs4
- 2. 在c中減小pdf的大小#
- 3. hadoop減少拆分大小
- 4. 如何在java中減少多部分文件的大小
- 5. SQL中減小的行大小並沒有減小表的大小
- 6. VBox中TableView的大小
- 7. 減小jdialog的大小
- 8. 減小EditField的大小
- 9. 減小igraph中的自環的大小
- 10. 如何減小materialize.js所有小部件的大小?
- 11. 減小WPF中XPS的大小
- 12. 減小java中圖像的大小
- 13. 從Flash Builder中減小swf的大小
- 14. 無法減小ios7中的iframe大小
- 15. 如何在大小小於1MB的部分中拆分列表
- 16. UIImage大小在tableView Cell
- 17. HTML - 減小頁面大小
- 18. Bootstrap減小字體大小
- 19. 減小函數大小
- 20. PowerShell - 減小圖像大小
- 21. 如何在原始文件夾中減小.mp3文件的大小以減小Android中.apk文件的大小?
- 22. 分別增大和減小字體的大小
- 23. 將ggplot中的圖例大小減小到默認大小
- 24. 在TableViewController中調整TableView的大小Swift
- 25. 減少外部jar文件的大小
- 26. 增加tableView Cell的大小..?
- 27. 縮小按鈕的大小減少了圖像的大小,而不是減小大小
- 28. 減小部署到websphere的war文件的大小
- 29. 減少TimePicker大小
- 30. 減少BitmapDrawable大小
你試過減少整個tableview的寬度? – 2011-05-21 11:39:09
@Nick Weaver:實際上我也不知道,我也想這樣做的部分和表格視圖 – sujay 2011-05-21 11:40:47
你可以用'myTableView.frame = CGRectMake(x,y,width,height)設置整個tableView的大小);'。您必須調整CGRectMake的值。該部分應該相應縮小。請嘗試一下,告訴我們是否適合您的需求。 – 2011-05-21 11:43:45