开发者

reducing size of the section in tableview

i am very much new to iphone development ,I wanted to re开发者_StackOverflow社区duce the size of a section in the grouped table view i.e reducing the width of the section . how can it be implemented thanks in advance


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


Hi add this UITableviewdelegate method

- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return height;
}


its a very simple soln ...

@interface MyController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableview *myTableview;

just right click on "UITableViewDelegate" and "UITableViewDataSource"

n implement all the delegates....u will find all types of adjustment over there....weather u want to change or adjust height or width of section or row ...or how many section or how many rows in a section do u want.... its simple n called automatically.... regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜