0

been trying to solved this for 3 days straight, but still nothing. so i want to control the alpha of an uiview using a slider inside a popview that appear from a rect button(button pressed) so here what i already did,

mainview .h file :

@class popView;
@interface brightscreenViewController : UIViewController <UIPopoverControllerDelegate>
{    
    IBOutlet UIView *darkView;
    IBOutlet UIButton *brightbtn;
    UIPopoverController *popvover;
    popView *pop;   
}

@property(nonatomic, retain) UIPopoverController *popover;
@property (nonatomic, retain) UIView *darkView;
@property (nonatomic, retain) popView *pop;

- (IBAction)showPop:(id)sender; 

mainview .m file :

#import "brightscreenViewController.h"
#import "popView.h"

@class popView;
@interface brightscreenViewController ()

@end

@implementation brightscreenViewController
@synthesize popover;
@synthesize darkView;
@synthesize pop;

-(IBAction)showPop:(id)sender
{    
    popView *brightpop = [[popView alloc] init];
    popover = [[UIPopoverController alloc] initWithContentViewController:brightpop];
    [popover setDelegate:self];
    [popover presentPopoverFromRect:[brightbtn bounds] inView:brightbtn permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    [popover setPopoverContentSize:CGSizeMake(229, 57)];
}

and on a second view .h which contain the uipopview and a slider :

@class brightscreenViewController;

@interface popView : UIViewController
{

    brightscreenViewController *brightscreen;
    IBOutlet UISlider *slider;   
}

@property (nonatomic, retain)UISlider *slider;
@property (nonatomic, retain) brightscreenViewController *brightscreen;

-(IBAction)setBrightness:(id)sender;

secondview .m file :

#import "popView.h"
#import "brightscreenViewController.h"


@interface popView ()

@end

@implementation popView
@synthesize slider;
@synthesize brightscreen;

-(IBAction)setBrightness:(id)sender
{   
    brightscreen.darkView.alpha = slider.value;
}

the pop over works just fine but not the slider. it just doesn't response at all. i already try to put the slider directly on the main view using the same code and it works just fine, but Not working when i put it with uipopover i really hope someone can help me with this.

redribbon
  • 41
  • 1
  • 10

1 Answers1

1

How about:

popView *brightpop = [[popView alloc] init];

// New line
brightpop.brightscreen = self;

popover = [[UIPopoverController alloc] initWithContentViewController:brightpop];
Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
  • hmm, can you help me with one more thing? everything works fine but now my text view that i put behind the darkView becomes unscrollable. i already try to put it in front of dark view but the text becomes bright. actually i want to set the brightness of the screen, but since apple doesn't provide the API to public so i use this trick to set up the brightness.so i need to set the alpha of the view but still manage to scroll the textview. any suggestion to this anyone? thanks in advance. – redribbon Jul 24 '12 at 07:43
  • I haven't tried that. You might want to start a new question so that people who know the answer will be able to find it. – Phillip Mills Jul 24 '12 at 11:14