how to control an outlet from another uiviewcontroller
-
22-06-2021 - |
Domanda
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.
Soluzione
How about:
popView *brightpop = [[popView alloc] init];
// New line
brightpop.brightscreen = self;
popover = [[UIPopoverController alloc] initWithContentViewController:brightpop];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow