如何从另一个uiviewcontroller控制出口



已经连续三天试图解决这个问题,但仍然一无所获。因此,我想使用从rect按钮(按下按钮)出现的popview中的滑块来控制uiview的alpha我已经做了什么,

mainview.h文件:

@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文件:

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

第二个视图.h包含uipopview和滑块:

@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文件:

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

@interface popView ()
@end
@implementation popView
@synthesize slider;
@synthesize brightscreen;
-(IBAction)setBrightness:(id)sender
{   
    brightscreen.darkView.alpha = slider.value;
}

弹出操作很好,但滑块不行。它根本没有反应。我已经尝试使用相同的代码将滑块直接放在主视图上,它运行得很好,但当我使用uipopover时就不起作用了我真的希望有人能帮我。

怎么样:

popView *brightpop = [[popView alloc] init];
// New line
brightpop.brightscreen = self;
popover = [[UIPopoverController alloc] initWithContentViewController:brightpop];

相关内容

  • 没有找到相关文章

最新更新