Question

I wants to add a subview (like google paging) in masterView of UISplitView, I simply add a subview but the subview also scroll with masterView tableView, how i fix that subView not scroll with tableView? May be I am going in wrong track, please direct me on right way, how I add subview in masterView of UISplitView.

thanks

- (void)viewDidLoad
{
[super viewDidLoad];


UIView *barView=[[UIView alloc]initWithFrame:CGRectMake(0, 500, 300,50)];
barView.backgroundColor=[UIColor redColor];
[self.view addSubview:barView];
}
Était-ce utile?

La solution

UITableView is a subclass of UIScrollView, so if your master view controller's main view is a table, any subviews are of course going to scroll. The solution is to create a view that will contain both the table and your barView. A plain old UIView will work fine for that.

Autres conseils

Try like this..Its help for you. you can change the frame of the sub view. Set the frame on the scrollViewDidScroll delegate.

- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (self.tableView)
    {
        NSLog(@"X = %f,Y = %f",scrollView.contentOffset.x,scrollView.contentOffset.y);
        NSLog(@"%f,%f",scrollView.contentSize.width,scrollView.contentSize.height);
        table_Y_Position = scrollView.contentOffset.y;
        barView.frame = CGRectMake(275, 665+scrollView.contentOffset.y, 31, 31);
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top