我收到一个错误,因为"没有更多上下文,表达的类型是模糊的"
这是我的代码
@IBOutlet var customerDashboardButtons:[NSArray]?
var predicate = NSPredicate(format: "SELF.tag == %d", tag)
var filteredButtons = customerDashboardButtons!.filter { predicate.evaluateWithObject($0) };
if 0 < filteredButtons.count {
var button = customerDashboardButtons!.first
button.hidden = true // getting an error in this line as "Type of expression is ambiguous without more context
}
Run Code Online (Sandbox Code Playgroud)
我试过以下,
var button:UIButton = customerDashboardButtons!.first //Error "NSArray? is not convertible to UIButton"
var button = customerDashboardButtons!.first as UIButton //Error "NSArray? is not convertible to UIButton"
Run Code Online (Sandbox Code Playgroud)
对此有任何帮助表示赞赏.
我已经从 developer.Apple 网站下载了示例代码GLPaint,以使用 OpenGL 在 Canvas 上绘制图片。
我对 GLPaint 应用程序进行了许多更改以满足我的要求。现在,我想将绘制的项目作为图像保存到照片库中。
我知道在照片库中保存图像的方法。所以,我尝试在绘制图片后创建相应的图像文件。你知道这样做的好方法是什么吗?对此的任何帮助表示高度赞赏。
代码细节描述如下。
绘画视图.h
EAGLContext *context;
// OpenGL names for the renderbuffer and framebuffers used to render to this view
GLuint viewRenderbuffer, viewFramebuffer;
// OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist)
GLuint depthRenderbuffer;
GLuint brushTexture;
CGPoint location;
CGPoint previousLocation;
Run Code Online (Sandbox Code Playgroud)
PaintView.m
// Handles the start of a touch
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGRect bounds = …Run Code Online (Sandbox Code Playgroud) 我从developer.Apple网站下载了示例代码GLPaint,使用OpenGL在Canvas上绘制图片.
我已经完成了GLPaint应用程序中的更改以满足我的要求.
现在我需要将绘图记录为m4v视频文件,该文件应该集成我在绘制图像时说出的口头指令.
例如:
点击"绘制和录制"按钮后,我开始画一个圆圈并说出"这是一个圆圈".
单击完成按钮后,结果应为包含绘图操作的视频文件,其中包含"这是一个圆圈"的声音
我研究了这个主题,但我没有找到任何好的方法来完成这个功能.
PaintingView.h EAGLContext*context;
// OpenGL names for the renderbuffer and framebuffers used to render to this view
GLuint viewRenderbuffer, viewFramebuffer;
// OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist)
GLuint depthRenderbuffer;
GLuint brushTexture;
CGPoint location;
CGPoint previousLocation;
Run Code Online (Sandbox Code Playgroud)
PaintingView.m
// Handles the start of a touch
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGRect bounds = [self bounds];
UITouch* touch = [[event touchesForView:self] …Run Code Online (Sandbox Code Playgroud) 我的目标是当我点击已经选择的段时再次触发 UIControlEventValueChanged委托.
所以我已经提到了以下链接
根据链接,我创建了一个uisegmentedcontrol子类,实现了该- (void) setSelectedSegmentIndex:(NSInteger)toValue {方法并编写了代码(来自上面的链接).
它与Ipad1配合得很好.但是,当点击已经选择的段时,继承/子类中的setSelectedSegmentIndex不会在Ipad2中触发!但是,当我点击未选择的段索引时,它工作正常.
我完成的代码如下
主类
ReselectableSegmentControl *firstNextSegmentedControl = [[ReselectableSegmentControl alloc] init];
firstNextSegmentedControl.frame = CGRectMake(xCordinate, 255, 188, 50);
firstNextSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
firstNextSegmentedControl.tag = index + 1;
[firstNextSegmentedControl addTarget:self action:@selector(firstNextThenSegmentedControlValueChanged:) forControlEvents:UIControlEventValueChanged];
[firstNextSegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"NoTimerCounter.png"] atIndex:0 animated:YES];
[firstNextSegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"Timer.png"] atIndex:1 animated:YES];
[firstNextSegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"Counter.png"] atIndex:2 animated:YES];
firstNextSegmentedControl.selectedSegmentIndex = 0;
[self.view addSubview:firstNextSegmentedControl];
[firstNextSegmentedControl release];
firstNextSegmentedControl = nil;
Run Code Online (Sandbox Code Playgroud)
UISegmentSubClass .h文件
#import <Foundation/Foundation.h>
@interface ReselectableSegmentControl : UISegmentedControl {
}
@end
Run Code Online (Sandbox Code Playgroud)
UISegmentSubClass .m文件
-(void)setSelectedSegmentIndex:(NSInteger …Run Code Online (Sandbox Code Playgroud) iphone objective-c uisegmentedcontrol ipad-2 uicontrolevents