简体   繁体   中英

add subView in master view on UISplitView

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM