UIpopover de control segmentado

Anyone know any links/tutorials on how to put a segmented control in a 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] ;
    }


}

Advice would be appreciated

preguntado el 31 de enero de 12 a las 08:01

Set frame before adding Firstview1, Secondview2 and Thirdview3 to self.view. -

1 Respuestas

first of all when you use segment control don't just add subviews in each segment because when you switch segments the subviews don't get removed .For the scroll view just change the content size .So the best way is that :-

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

}

Respondido el 03 de diciembre de 12 a las 08:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.