我如何投射到派生类?以下方法都会出现以下错误:
无法从BaseType转换为DerivedType.没有构造函数可以采用源类型,或构造函数重载解析是不明确的.
BaseType m_baseType;
DerivedType m_derivedType = m_baseType; // gives same error
DerivedType m_derivedType = (DerivedType)m_baseType; // gives same error
DerivedType * m_derivedType = (DerivedType*) & m_baseType; // gives same error
Run Code Online (Sandbox Code Playgroud) 我现在试图隐藏iOS 4.3中的状态栏,现在setStatusBarHidden:animated:
已弃用:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]; //deprecated
Run Code Online (Sandbox Code Playgroud)
plist文件中唯一存在的选项是:状态栏最初是隐藏的.这只会隐藏应用程序开头的状态栏.
干杯
我正在尝试将一个库添加到Visual Studio C++项目中,但是,当我转到项目属性时,我只有选项,
Common Properties
Startup Project
Project Dependencies
Debug Source File
Configuration Properites
Configuration
Run Code Online (Sandbox Code Playgroud)
为什么我看不到链接器选项?
我知道这个问题已经在网站上被问了很多,但是,我似乎无法找到解决方案.当应用程序未运行时,不会调用我的BOOT_COMPLETED接收器.
表现:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.startuptest"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="internalOnly">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.startuptest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.example.startuptest.StartUpBootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
StartUpBootReceiver:
public class StartUpBootReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("startuptest", "StartUpBootReceiver " + intent.getAction());
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
Log.d("startuptest", "StartUpBootReceiver BOOT_COMPLETED");
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果应用程序正在运行,我用模拟呼叫
adb shell
am broadcast -a …
Run Code Online (Sandbox Code Playgroud) 我需要能够同时拥有AVCaptureVideoDataOutput
和AVCaptureMovieFileOutput
工作.以下代码有效,但视频录制没有.在didFinishRecordingToOutputFileAtURL
直接后调用委托startRecordingToOutputFileURL
被调用.现在,如果我AVCaptureVideoDataOutput
从
AVCaptureSession
简单的评论中删除该行:
[captureSession addOutput:captureDataOutput];
视频录制工作,但然后不调用SampleBufferDelegate(我需要).
我怎样才能兼顾AVCaptureVideoDataOutput
并AVCaptureMovieFileOutput
同时工作.
- (void)initCapture {
AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] error:NULL];
captureDataOutput = [[AVCaptureVideoDataOutput alloc] init];
[captureDataOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
m_captureFileOutput = [[AVCaptureMovieFileOutput alloc] init];
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key];
[captureDataOutput setVideoSettings:videoSettings];
captureSession = [[AVCaptureSession alloc] init];
[captureSession addInput:captureInput];
[captureSession addOutput:m_captureFileOutput];
[captureSession addOutput:captureDataOutput];
[captureSession beginConfiguration];
[captureSession setSessionPreset:AVCaptureSessionPresetLow];
[captureSession commitConfiguration];
[self performSelector:@selector(startRecording) …
Run Code Online (Sandbox Code Playgroud) 我想知道是否有一种简单的方法来访问IOS中的主窗口或视图.类似的东西:
[UIScreen mainScreen]
Run Code Online (Sandbox Code Playgroud)
谢谢.
我使用rails 4.0.3并尝试在Active-Admin中设置多个复选框.复选框选项未保存.这就是我所拥有的
class Product < ActiveRecord::Base
has_many :categorizations
has_many :categories, :through => :categorizations
accepts_nested_attributes_for :categorizations
end
class Category < ActiveRecord::Base
has_many :categorizations
has_many :products, :through => :categorizations
accepts_nested_attributes_for :categorizations
end
class Categorization < ActiveRecord::Base
belongs_to :category
belongs_to :product
end
ActiveAdmin.register Product do
permit_params :title, :price, category_ids:[:id]
form do |f|
f.semantic_errors *f.object.errors.keys
f.inputs "Product" do
f.input :title
f.input :price
f.input :categories, :as => :check_boxes
end
f.actions
end
end
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用has_and_belongs_to_many,但仍然无法获得保存的选择.
任何指导都将受到高度赞赏.
干杯
我正在寻找有关如何在IOS上播放midi文件的一些信息.我不需要任何midi输入或输出消息.我只想阅读midi文件并将曲目播放给用户,将每个音符替换为钢琴声音样本.能够调节节奏将是另一个要求.
请注意,我没有兴趣将midi文件转换为wav或其他格式.我想直接读取midi文件.
任何人都可以向我指出一些可能有助于我理解所需过程的信息.
干杯
我似乎无法让nsdata写入文件.我有什么想法可能做错了.提前致谢.
NSString* filename = @"myfile.txt";
NSString *applicationDocumentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:filename];
if ([fileManager fileExistsAtPath:applicationDocumentsDir])
NSLog(@"applicationDocumentsDir exists"); // verifies directory exist
NSData *data = [NSData dataWithContentsOfURL:URL];
if (data) {
NSString *content = [[NSString alloc] initWithBytes:[data bytes]
length:[data length] encoding: NSUTF8StringEncoding];
NSLog(@"%@", content); // verifies data was downloaded correctly
NSError* error;
[data writeToFile:storePath options:NSDataWritingAtomic error:&error];
if(error != nil)
NSLog(@"write error %@", error);
}
Run Code Online (Sandbox Code Playgroud)
我一直在收到错误
"The operation couldn’t be completed. No such file or directory"
Run Code Online (Sandbox Code Playgroud) ios ×5
c++ ×2
.net ×1
activeadmin ×1
android ×1
camera ×1
checkbox ×1
inheritance ×1
inverse ×1
iphone ×1
linker ×1
midi ×1
nsdata ×1
quaternions ×1
record ×1
statusbar ×1
uiview ×1
window ×1
writetofile ×1