我正在像AVFoundation一样拍照:http://red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/
一个片段:
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
CFDictionaryRef exifAttachments = CMGetAttachment( imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
if (exifAttachments)
{
// Do something with the attachments.
NSLog(@"attachements: %@", exifAttachments);
}
else
NSLog(@"no attachments");
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
Run Code Online (Sandbox Code Playgroud)
我发现的图片大小设置在这里:
AVCaptureSession *session = [[AVCaptureSession alloc] init];
session.sessionPreset =AVCaptureSessionPresetMedium; //medium on my iphone4 is 640*480
Run Code Online (Sandbox Code Playgroud)
但是这里只有少数几种设置,并且无法设置为自定义大小.
如果可能的话,我想拍照片的宽高比为1:1,例如400x400像素(方形图片).看来instagram正在这样做(或者是裁剪图像?).
如何指定拍摄照片的大小为正方形?我知道如何改变手机的尺寸,但如果拍摄的照片不是正方形,结果就不好了.
任何的想法?
虽然有些问题被接受,但我看到了许多类似的问题,但没有很好的答案.我已注册C2DM.我收到了确认邮件.然后我写了一些简单的应用程序来注册C2DM.我得到了id(在模拟器和真实设备上试过).然后我获得了我用于C2DM注册的电子邮件的auth令牌(带卷曲)(我在app中用来获取id的电子邮件).
当我尝试执行推送(也使用curl)时,我收到401错误(就像auth令牌错误一样).
我阅读了很多教程,但我的想法已经不多了.
我需要从我的应用程序拨打电话后返回我的应用程序,所以我使用此代码:
NSURL *url = [NSURL URLWithString:@"telprompt://123-4567-890"];
[[UIApplication sharedApplication] openURL:url];
Run Code Online (Sandbox Code Playgroud)
当用户按下按钮执行此代码时,会显示一个警告,其中包含2个按钮,"呼叫"和"取消".
如何确定用户是否按下了"呼叫"按钮?
我正在使用viewpager在两个操作栏选项卡之间滑动(使用eclipse向导进行此类导航).我正在使用android maps v2 api.
我想在我的一个标签里面有mapview,button和textview(我猜想有mapfragment是不可能的).
我从xml为我的片段扩充布局,如下所示:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.first_tab_fragment, container, false);
}
}
Run Code Online (Sandbox Code Playgroud)
我的first_tab_fragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.android.gms.maps.MapView
android:id="@+id/mapview"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/textView1"
android:layout_marginRight="15dp" >
</com.google.android.gms.maps.MapView>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_centerHorizontal="true"
android:text="Button" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/button1"
android:layout_marginBottom="133dp"
android:text="TextView" />
Run Code Online (Sandbox Code Playgroud)
不显示MapView,只显示textview和按钮.我也没有错.我是否必须编写一些代码来初始化mapview?
java android android-fragments android-viewpager android-maps-v2
当用户注销时,我需要Mixpanel忘记distinct_id.在iOS应用程序中,我调用reset(https://mixpanel.com/site_media/doctyl/uploads/iPhone-spec/Classes/Mixpanel/index.html#//apple_ref/occ/instm/Mixpanel/reset)并且它可以正常工作.
我无法在Android mixpanel文档中找到正确的调用,我尝试调用clearSuperProperties(),但distinct_id仍然存在.
现在,如果你想用你的android测试标签,你必须使用fakeTagsActivity(http://developer.android.com/resources/samples/NFCDemo/src/com/example/android/nfc/simulator/FakeTagsActivity.html)应用.Android团队是否计划将此功能包含在模拟器中,因此您只需点击一下即可创建RFID标签并将其"连接"到手机上?这款产品在诺基亚6212附带的2年诺基亚NFC管理器中得到了很好的实施(http://www.forum.nokia.com/info/sw.nokia.com/id/5bcaee40-d2b2-4595-b5b5-4833d6a4cda1 /S40_Nokia_6212_NFC_SDK.html).
不知怎的偏离主题,除了官方页面的那些,在Android中使用NFC有什么好的代码示例吗?
谢谢.
如果我只为我的textview设置边距,那就是线性布局,一切正常.如果我只为我的textview设置重力,它就有效.但是如果我设置了两个属性(重力和边距),重力仍然保留,边缘设置成功.
我的代码用于设置两个不按预期工作的属性:
tv2=new TextView(this);
tv2.setText("Text");
LinearLayout.LayoutParams para=new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT );
para.setMargins(0, 10, 0, 10); //left,top,right, bottom
tv2.setLayoutParams(para);
tv2.setGravity(android.view.Gravity.CENTER_HORIZONTAL);
Run Code Online (Sandbox Code Playgroud)
我必须在代码中构建我的布局,不能使用xml文件.
我试图在模拟器API 10(Android 2.3.3)中测试ForegroundDispatch(http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/nfc/ForegroundDispatch.html).
当我调用NfcAdapter.getDefaultAdapter(this)时,我得到null.为什么会这样?
码:
public class ForegroundDispatch extends Activity {
private NfcAdapter mAdapter;
private PendingIntent mPendingIntent;
private IntentFilter[] mFilters;
private String[][] mTechLists;
private TextView mText;
private int mCount = 0;
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
setContentView(R.layout.foreground_dispatch);
mText = (TextView) findViewById(R.id.text);
mText.setText("Scan a tag");
mAdapter = NfcAdapter.getDefaultAdapter(this);
// Create a generic PendingIntent that will be deliver to this activity. The NFC stack
// will fill in the intent with the details of the discovered tag before delivering to …Run Code Online (Sandbox Code Playgroud) 我来自Android,刚刚开始学习iOS开发.如何从代码中引用Interface Builder中创建的UI元素?在Android中,这可以通过该功能完成findViewById().
什么是iOS SDK相当于findViewById()?
我正在从事 kotlin 多平台项目。我成功地向我的 build.gradle 添加了几个库(ktor、协程等)。我还将 sqldelight 添加到 common、android 和 ios 源集。我的 ios 依赖是这样定义的:
implementation "com.squareup.sqldelight:native-driver:1.4.0"
Run Code Online (Sandbox Code Playgroud)
Gradle 说一切都很好。android编译代码:
actual fun createDb(): ToshlDatabase? {
val driver = AndroidSqliteDriver(ToshlDatabase.Schema, appContext, "toshl.db")
return ToshlDatabase(driver)
Run Code Online (Sandbox Code Playgroud)
}
ios的代码没有,它没有找到“NativeSqliteDriver”:
actual fun createDb(): ToshlDatabase? {
val driver = NativeSqliteDriver(ToshlDatabase.Schema, "toshl.db");
return ToshlDatabase(driver)
Run Code Online (Sandbox Code Playgroud)
}
我尝试使用旧版本的 com.squareup.sqldelight 但它没有帮助。这个东西怎么调试?
编辑:我共享的 build.gradle:
plugins {
id("org.jetbrains.kotlin.multiplatform")
id("com.android.library")
id ("org.jetbrains.kotlin.native.cocoapods")
id("kotlinx-serialization")
id("com.squareup.sqldelight")
}
ext.coroutine_version = '1.3.5-native-mt'
ext.serializer_version = '0.20.0'
ext.ktor_version = '1.3.2'
ext.sqlDelight_version= '1.4.0'
android {
compileSdkVersion 29
buildToolsVersion '30.0.0'
defaultConfig {
minSdkVersion 21 …Run Code Online (Sandbox Code Playgroud) android ×8
java ×4
iphone ×3
ios ×2
nfc ×2
android-c2dm ×1
avfoundation ×1
camera ×1
gravity ×1
instagram ×1
layout ×1
margin ×1
mixpanel ×1
nsurl ×1
objective-c ×1
sqldelight ×1
uiimage ×1