连续3天试图解决这个问题,但仍然没有。所以我想使用从矩形按钮(按下按钮)出现的弹出视图中的滑块来控制 uiview 的 alpha,所以这里我已经做了,
主视图 .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;
主视图 .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)];
}
在包含 uipopview 和滑块的第二个视图 .h 上:
@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 上时不起作用我真的希望有人能帮助我。