Question

I added Tableview on xib file(you can see on image).tableview is loading well . But last cell is out of screen so when I Swipe Up last index is showing. When I get off my hand, last cell is not appear. I don't change any height of tableview . Why not fixed to my screen ?

I am using reveal menu like facebook in this project : https://github.com/mikefrederick/MFSideMenu

Also You can see problem on movie.

https://www.dropbox.com/s/usfwdhl5w9znkl6/IMG_0006.MOV

movie:

viewcontroller.h

@property(nonatomic,retain)IBOutlet UITableView * tableview;

viewcontroller.m

-(void)viewDidAppear:(BOOL)animated
{
     self.tableview.backgroundColor=[UIColor colorWithRed:(28/255.0) green:(28/255.0) blue:(28/255.0) alpha:1];
     [self.tableview setSeparatorColor:[UIColor blackColor]];

}
- (void)viewDidLoad
{
    [super viewDidLoad];




    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
        self.edgesForExtendedLayout = UIRectEdgeNone;

}
#pragma mark -
#pragma mark - UITableViewDataSource


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0)
    {
        return 5;
    }
    if (section==1)
    {
        return 3;
    }
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.textLabel.text =@"exampleCell";



    NSLog(@"cell.contentView.bounds.size.width %1.0f",cell.contentView.bounds.size.width);
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if(section == 1)
        return 40;
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   self.tableview.layer.cornerRadius = 10.0f;
    tableView.layer.borderWidth = 2.0;
    tableView.layer.borderColor = [UIColor redColor].CGColor;
    return 60;


}
#pragma mark UITableViewDelegate
- (void)tableView: (UITableView*)tableView
  willDisplayCell: (UITableViewCell*)cell
forRowAtIndexPath: (NSIndexPath*)indexPath
{

    cell.backgroundColor =[UIColor colorWithRed:(41/255.0) green:(41/255.0) blue:(41/255.0) alpha:1];
    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.detailTextLabel.backgroundColor = [UIColor clearColor];
    if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){
        //end of loading
        //for example [activityIndicator stopAnimating];

    }
}

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
    [headerView setBackgroundColor:[UIColor colorWithRed:(112/255.0) green:(112/255.0) blue:(112/255.0) alpha:1]];
    UILabel *titleLabel = [ [UILabel alloc] initWithFrame:CGRectMake(20, 0, 300, 44)];

    titleLabel.text = @"MÜŞTERİ ALANI";

    titleLabel.textColor = [UIColor whiteColor];

    titleLabel.backgroundColor = [UIColor clearColor];

    [headerView addSubview:titleLabel];
    return headerView;
}
Était-ce utile?

La solution

In your video, this menu appears to be a slide out menu, presumably using some third party slide out menu controller library. So this view controller is contained within some container view from that. It is possible that the slide out menu controller isn't properly sizing your view controller to fit its container view.

One solution would be to check any example apps that come with the slide out controller you're using to see if they suffer from the bug and report this to the developer if it is the case. This would be good because other developers would benefit from the improvements. In fact it's possible the slide out controller you're using has fixed this bug with a newer version already that you don't have yet.

Another solution, assuming there's an example app that doesn't suffer from this, is to see how it is adding its slide out menu and see if you're failing to do something that they're doing.

Lastly, if there's no example app or you can't figure out why theirs is working differently, try adding the following to your view controller's viewDidAppear: method:

self.view.frame = self.view.superview.bounds;

This assumes that the container view they create is properly sized.

Autres conseils

Your problem seems to be in your xib. You have to set the size of your View to "Freeform" then add autosizing constraints on your view like you did on your tableView.

Freeform

Autosizing

first you should select the CELL, not the TABLE VIEW. Next, go to the attribute inspector and click the separator, and you should select the custom inserts. Lastly you can adjust the separator line according to your wish. Hope this will help you and others. Thanks for the question too.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top