0

任何人都知道有关如何将分段控件放入 UIpopover 的任何链接/教程?one of the views has a scroll view and when the segment index is selected the scroll view appears on top of the rest of the popover and the segment cannot be selected

- (IBAction) segmentAction:(id)sender 
{
    UISegmentedControl* control = sender ;

    if( [control selectedSegmentIndex] == 0 )
    {

        [ self.view addSubview:Firstview1] ;
    }
    if( [control selectedSegmentIndex] == 1 ) 
    {  

        [scrollview1 setScrollEnabled:YES];
        [scrollview1 setContentSize:CGSizeMake(320, 480)];
        self->Secondview2=scrollview1;
        [scrollview1 release];

        [ self.view addSubview:Secondview2] ;
    }
    if( [control selectedSegmentIndex] == 2 ) 
    {
        [ self.view addSubview:Thirdview3] ;
    }


}

建议将不胜感激

4

1 回答 1

1

首先,当您使用段控制时,不要只在每个段中添加子视图,因为当您切换段时,子视图不会被删除。对于滚动视图,只需更改内容大小。所以最好的方法是:-

viewDidLoad()
{
[ self.view addSubview:Firstview1] ;
Firstview1.hidden = yes;
[ self.view addSubview:Secondview2] ;
Secondview2.hidden = yes;
[ self.view addSubview:Thirdview3] ;
Thirdview3.hidden = yes;

}

(IBAction) segmentAction:(id)sender 
{
    UISegmentedControl* control = sender ;

    if( [control selectedSegmentIndex] == 0 )
    {
Firstview1.hidden = no;
       Secondview2.hidden = yes;
Thirdview3.hidden = yes;
    }
    if( [control selectedSegmentIndex] == 1 ) 
    {  

        [scrollview1 setScrollEnabled:YES];
        [scrollview1 setContentSize:CGSizeMake(320, 480)];
        self->Secondview2=scrollview1;
        [scrollview1 release];

       Firstview1.hidden = yes;
       Secondview2.hidden = no;
Thirdview3.hidden = yes;
    }
    if( [control selectedSegmentIndex] == 2 ) 
    {
        Firstview1.hidden = yes;
       Secondview2.hidden = yes;
Thirdview3.hidden = no;
    }

}

于 2012-12-03T04:49:17.657 回答